0

I am trying to following this suggestion.

outputs = Conv2DTranspose(3, (1, 1), activation='sigmoid') (c9)
model = Model(inputs=[inputs], outputs=[outputs])
model = multi_gpu_model(model, gpus=8)
model.compile(optimizer='adam', loss = bce, metrics = [mean_iou])
model.add(Lambda(lambda x: K.batch_flatten(x)))

But at that last line of code, I receive the following error:

'Model' object has no attribute 'add'

I understand that since I didn't instantiate model as sequential() as in linked post, the function add() might not be available to me. However, I'm not sure how to work around this.

Jonathan
  • 1,876
  • 2
  • 20
  • 56

2 Answers2

1

Corrected to reflect the working solution:

outputs = Conv2DTranspose(3, (1, 1), activation='sigmoid') (c9)
outputs = Lambda(lambda x: K.batch_flatten(x))(outputs)
model = Model(inputs=[inputs], outputs=[outputs])
model = multi_gpu_model(model, gpus=8)
model.compile(optimizer='adam', loss = bce, metrics = [mean_iou])
swiftg
  • 346
  • 1
  • 9
  • IN that situation, I got this error: `Output tensors to a Model must be the output of a TensorFlow Layer (thus holding past layer metadata). Found: ` – Jonathan Jul 09 '18 at 21:59
0

Going off @Today's answer in the OP's comments,

outputs = Lambda(lambda x: K.batch_flatten(x))(outputs)

Jonathan
  • 1,876
  • 2
  • 20
  • 56