keras merge AttributeError: 'Merge' object has no attribute 'is_placeholder'
keras merge AttributeError: 'Merge' object has no attribute 'is_placeholder'
我一直在尝试弄一些开源代码给运行,但是可以摆脱这一个错误。
mnist = input_data.read_data_sets('../../MNIST_data', one_hot=True)
X_train = mnist.train.images
y_train = mnist.train.labels
X = Input(batch_shape=(m, n_x))
cond = Input(batch_shape=(m, n_y))
merged = merge([X, cond], mode='concat', concat_axis=1)
inputs = merged # I tried sub X instead of merged, then it works
...................
# middle layer code derives outputs, which is irrelevant to this error
vae = Model(inputs, outputs)
重要的是最后一行抱怨没有属性。
File "cvae_keras.py", line 74, in <module>
vae = Model(inputs, outputs)
File "/Users/bruceho/anaconda/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 88, in wrapper
return func(*args, **kwargs)
File "/Users/bruceho/anaconda/lib/python2.7/site-packages/keras/engine/topology.py", line 1566, in __init__
if layer.is_placeholder:
AttributeError: 'Merge' object has no attribute 'is_placeholder'
但是merged和X都是tensorflow.python.framework.ops.Tensor类型,如果我换出merged作为输入,用X替换,就不会出现这样的错误。
为什么语句不接受 Tensor 对象的合并版本?
创建模型时不需要合并输入。
mnist = input_data.read_data_sets('../../MNIST_data', one_hot=True)
X_train = mnist.train.images
y_train = mnist.train.labels
X = Input(batch_shape=(m, n_x))
cond = Input(batch_shape=(m, n_y))
...................
# do whatever you want to create outputs from X and cond
vae = Model(inputs = [X, cond], outputs=outputs)
查看更多
我一直在尝试弄一些开源代码给运行,但是可以摆脱这一个错误。
mnist = input_data.read_data_sets('../../MNIST_data', one_hot=True)
X_train = mnist.train.images
y_train = mnist.train.labels
X = Input(batch_shape=(m, n_x))
cond = Input(batch_shape=(m, n_y))
merged = merge([X, cond], mode='concat', concat_axis=1)
inputs = merged # I tried sub X instead of merged, then it works
...................
# middle layer code derives outputs, which is irrelevant to this error
vae = Model(inputs, outputs)
重要的是最后一行抱怨没有属性。
File "cvae_keras.py", line 74, in <module>
vae = Model(inputs, outputs)
File "/Users/bruceho/anaconda/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 88, in wrapper
return func(*args, **kwargs)
File "/Users/bruceho/anaconda/lib/python2.7/site-packages/keras/engine/topology.py", line 1566, in __init__
if layer.is_placeholder:
AttributeError: 'Merge' object has no attribute 'is_placeholder'
但是merged和X都是tensorflow.python.framework.ops.Tensor类型,如果我换出merged作为输入,用X替换,就不会出现这样的错误。
为什么语句不接受 Tensor 对象的合并版本?
创建模型时不需要合并输入。
mnist = input_data.read_data_sets('../../MNIST_data', one_hot=True)
X_train = mnist.train.images
y_train = mnist.train.labels
X = Input(batch_shape=(m, n_x))
cond = Input(batch_shape=(m, n_y))
...................
# do whatever you want to create outputs from X and cond
vae = Model(inputs = [X, cond], outputs=outputs)
查看更多