Keras: Cannot find Tensor() function to update Model to Keras2 API

Created on 11 Aug 2017  路  3Comments  路  Source: keras-team/keras

The code gets warning
UserWarning: Update your Model call to the Keras 2 API: Model(inputs=Tensor("in..., outputs=Tensor("de...)
But the Tensor function cannot be found in the Keras models.


from keras.layers import Input, Dense
from keras.models import Model
from keras.datasets import mnist
import numpy as np

num_hidden = 16
num_col_img = 28
num_row_img = 28
num_all_img = num_col_img*num_row_img

input_img = Input(shape=(num_all_img, ))
op_encode = Dense(num_hidden, activation='relu')(input_img)
op_decode = Dense(num_all_img, activation='sigmoid')(op_encode)
autoencoder = Model(input=input_img, output=op_decode)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')

Most helpful comment

Tensor is the type. The warning is about the argument renaming between Keras2 and Keras1
so :
autoencoder = Model(input=input_img, output=op_decode)
become
autoencoder = Model(inputs=input_img, outputs=op_decode)

All 3 comments

Tensor is the type. The warning is about the argument renaming between Keras2 and Keras1
so :
autoencoder = Model(input=input_img, output=op_decode)
become
autoencoder = Model(inputs=input_img, outputs=op_decode)

@Dref360 Great, now I understand. Sorry for not noticing the difference between inputs and input. I thought I need to change the type. Thank you very much.

Yeah, I was confused as well.

Was this page helpful?
0 / 5 - 0 ratings