'ListWrapper' object has no attribute 'get_config' error when saving nested model

Viewed 641

On Tensorflow 2.3.0, I am using Tensorflow Keras WideDeep model and am having an issue when calling model.save(path).

The error I am receiving is AttributeError: 'ListWrapper' object has no attribute 'get_config'

I have tested my code with other models and the save function works properly.

I also noticed that tensorflow.keras.utils.plot_model(model, path+f'{modelName}.png', show_shapes=True, rankdir='TB', expand_nested=True) does not render a graph.

The original model used tensorflow.keras LinearModel for the wide and a DNN for the deep. After reading this link, I have tried taking out the WideDeep and Linear Keras models and rebuilding as functional nested models. My new setup has a similar error AttributeError: 'ListWrapper' object has no attribute '_HAS_AGGREGATE_GRAD'

I think my error has something to do with using multiple inputs passed in as a list to a nested model. Has anyone had similar experiences saving Tensorflow Keras WideDeep or functional nested models?

A link to a copy of my code. The error message is presented in "Evaluate Network:Test Model"

Thank you.

1 Answers

First, sorry for my non-professional answer.

I had that problem, too.

If your train feature 1 is train_feature_1, then

Instead of model.fit( [train_feature_1, train_feature_2], [train_label_1, train_label_2], epochs = 2 )

Put [np.array(train_feature_1), np.array(train_feature_2)] in model.fit(~~~)

Related