You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am implementing the autoencoder code at https://jovian.ai/1potdish/autoencoder-tensorflow-pytorch
where I can successfully complete
optimizer = keras.optimizers.Adam()
loss = keras.losses.MeanSquaredError
model.compile(optimizer=optimizer, loss= loss, metrics=["accuracy"])
model.fit(x , x, epochs=20)
which ends with
<keras.src.callbacks.history.History object at 0x00000230CA119DF0>
However the next line produces an Error
mm = keras.Model(inputs=model.input, outputs=model.output)
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\covelld\AppData\Local\anaconda3\Lib\site-packages\keras\src\ops\operation.py", line 254, in input
return self._get_node_attribute_at_index(0, "input_tensors", "input")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\covelld\AppData\Local\anaconda3\Lib\site-packages\keras\src\ops\operation.py", line 285, in _get_node_attribute_at_index
raise ValueError(
ValueError: The layer sequential_6 has never been called and thus has no defined input.
Blogs indicate various ways to call to last sequential layer, non of which eliminate the Error.
If anyone on the Keras/Team could offer a suggestion, that would be appreciated. I do not know whether this is a keras
issue of a tensorflow issue. Regardless, I have made no progress on this issue, and I see that it is a common Error.
But the exact solution is unclear.
Thanks in advance
David Covell, Ph.D.
NIH-NCI
The text was updated successfully, but these errors were encountered:
Thanks for reporting the issue. Here CAE model is created using Squential keras API and later trying to creating model with Functional API here mm = keras.Model(inputs=model.input, outputs=model.output) using Sequential model inputs and output. But Squential model of keras doesn't have input and output.
By creating CAE model using Functional API will resolve the error.
def CAE(input_shape=(28, 28, 1), filters=[32, 64, 128, 10]):
input_layer = keras.layers.Input(shape=input_shape)
if input_shape[0] % 8 == 0:
pad3 = 'same'
else:
pad3 = 'valid'
x = keras.layers.Conv2D(filters[0], 5, strides=2, padding='same', activation='relu', name='conv1')(input_layer)
x = keras.layers.Conv2D(filters[1], 5, strides=2, padding='same', activation='relu', name='conv2')(x)
x = keras.layers.Conv2D(filters[2], 3, strides=2, padding=pad3, activation='relu', name='conv3')(x)
x = keras.layers.Flatten()(x)
x = keras.layers.Dense(units=filters[3], name='embedding')(x)
x = keras.layers.Dense(units=filters[2]*int(input_shape[0]/8)*int(input_shape[0]/8), activation='relu')(x)
x = keras.layers.Reshape((int(input_shape[0]/8), int(input_shape[0]/8), filters[2]))(x)
x = keras.layers.Conv2DTranspose(filters[1], 3, strides=2, padding=pad3, activation='relu', name='deconv3')(x)
x = keras.layers.Conv2DTranspose(filters[0], 5, strides=2, padding='same', activation='relu', name='deconv2')(x)
output_layer = keras.layers.Conv2DTranspose(input_shape[2], 5, strides=2, padding='same', name='deconv1')(x)
model = keras.Model(inputs=input_layer, outputs=output_layer)
model.summary()
return model
I am implementing the autoencoder code at https://jovian.ai/1potdish/autoencoder-tensorflow-pytorch
where I can successfully complete
optimizer = keras.optimizers.Adam()
loss = keras.losses.MeanSquaredError
model.compile(optimizer=optimizer, loss= loss, metrics=["accuracy"])
model.fit(x , x, epochs=20)
which ends with
<keras.src.callbacks.history.History object at 0x00000230CA119DF0>
However the next line produces an Error
mm = keras.Model(inputs=model.input, outputs=model.output)
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\covelld\AppData\Local\anaconda3\Lib\site-packages\keras\src\ops\operation.py", line 254, in input
return self._get_node_attribute_at_index(0, "input_tensors", "input")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\covelld\AppData\Local\anaconda3\Lib\site-packages\keras\src\ops\operation.py", line 285, in _get_node_attribute_at_index
raise ValueError(
ValueError: The layer sequential_6 has never been called and thus has no defined input.
Blogs indicate various ways to call to last sequential layer, non of which eliminate the Error.
If anyone on the Keras/Team could offer a suggestion, that would be appreciated. I do not know whether this is a keras
issue of a tensorflow issue. Regardless, I have made no progress on this issue, and I see that it is a common Error.
But the exact solution is unclear.
Thanks in advance
David Covell, Ph.D.
NIH-NCI
The text was updated successfully, but these errors were encountered: