问题
I am trying to make a fully connected model using tensorflow.keras, here is my code
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, Dense, Flatten
def load_model(input_shape):
input = Input(shape = input_shape)
dense_shape = input_shape[0]
x = Flatten()(input)
x = Dense(dense_shape, activation='relu')(x)
x = Dense(dense_shape, activation='relu')(x)
x = Dense(dense_shape, activation='relu')(x)
x = Dense(dense_shape, activation='relu')(x)
x = Dense(dense_shape, activation='relu')(x)
output = Dense(10 , activation = 'softmax')
model = Model(input , output)
model.summary()
return model
but when I call the model
model = load_model((120,))
I have this error
'Dense' object has no attribute 'op'
How can I fix this?
回答1:
Try
output = Dense(10 , activation = 'softmax')(x)
来源:https://stackoverflow.com/questions/61083004/dense-object-has-no-attribute-op