我是tensorflow的新手:我有tf版本0.8和cuda 7.5這是我的代碼: 我的numpy版本是1.11我認爲(不確定) 我該如何解決它?它說沒有模塊名稱堆棧? 我想實現自動編碼器變tensorflow模塊沒有堆棧方法
import tensorflow as tf
import numpy as np
from libs.utils import weight_variable, bias_variable, montage_batch
def VAE(input_shape=[None, 784],
n_components_encoder=2048,
n_components_decoder=2048,
n_hidden=2,
debug=False):
# %%
# Input placeholder
if debug:
input_shape = [50, 784]
x = tf.Variable(np.zeros((input_shape), dtype=np.float32))
else:
x = tf.placeholder(tf.float32, input_shape)
activation = tf.nn.softplus
dims = x.get_shape().as_list()
n_features = dims[1]
W_enc1 = weight_variable([n_features, n_components_encoder])
b_enc1 = bias_variable([n_components_encoder])
h_enc1 = activation(tf.matmul(x, W_enc1) + b_enc1)
W_enc2 = weight_variable([n_components_encoder, n_components_encoder])
b_enc2 = bias_variable([n_components_encoder])
h_enc2 = activation(tf.matmul(h_enc1, W_enc2) + b_enc2)
W_log_sigma = weight_variable([n_components_encoder, n_hidden])
b_log_sigma = bias_variable([n_hidden])
z_mu = tf.matmul(h_enc3, W_mu) + b_mu
z_log_sigma = 0.5 * (tf.matmul(h_enc3, W_log_sigma) + b_log_sigma)
# %%
# Sample from noise distribution p(eps) ~ N(0, 1)
if debug:
epsilon = tf.random_normal(
[dims[0], n_hidden])
else:
epsilon = tf.random_normal(
tf.stack([tf.shape(x)[0], n_hidden]))
和日誌是:
File "/home/hoda/Downloads/tensorflow_tutorials-master/python/11_variational_autoencoder.py", line 58, in VAE
tf.stack([tf.shape(x)[0], n_hidden]))
AttributeError: 'module' object has no attribute 'stack'
_「它說沒有模塊名稱堆棧」_ - 不,它不!錯誤是告訴你你的'tensorflow'模塊沒有'stack'方法。文檔說['tf.stack'](https://www.tensorflow.org/api_docs/python/tf/stack)確實存在 - 但是您必須使用太舊版本 – Eric
我正在使用tensorflow 0.8。 0 bcz我有cuda7!哪個版本應該安裝bcz最新的唯一worl與cuda8 –