'Dense' object has no attribute 'op'

落爺英雄遲暮 提交于 2020-12-08 06:11:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!