Reputation: 3572
I have been trying to get some open source code to run, but can get out of this one error.
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)
The important thing is the last line which blows up complaining about no attribute.
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'
But both merged and X are of the type tensorflow.python.framework.ops.Tensor, and if I swap out merged as input, and sub with X, then no such error.
Why wouldn't the statement accept the merged version of the Tensor object?
Upvotes: 1
Views: 808
Reputation: 457
You don't need to merge the inputs when creating model.
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)
Check more at the Keras Model document
Upvotes: 3