Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Dense' object has no attribute 'op' [closed]

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?

like image 345
Mohamed Mostafa Avatar asked Apr 07 '20 14:04

Mohamed Mostafa


1 Answers

You are missing (x) after your output layer. Try

output = Dense(10 , activation = 'softmax')(x)
like image 71
rikkatti Avatar answered Oct 11 '22 15:10

rikkatti