Week 3 Assignment 1 model.load_weights('models/model.h5')

I get an error on: model.load_weights(‘models/model.h5’)

The error I get is the following.

ValueError: You are trying to load a weight file containing 5 layers into a model with 14 layers.

Weird thing is that all unit tests have passed until this point.

In the cell that prints model.summary(), do you get the correct" Expected Output"?
There isn’t any unit test for that, you have it check it yourself.

Also, keep in mind that passing the unit tests doesn’t prove your code is perfect. There are lots of errors the unit tests are not designed to catch.

@TMosh Thanks for pointing me in the right direction. I had a problem in my Dense layer where I had too many of them, so the number of parameters was not correct. I have it working now.

I got the same error because I defined a new layer as Dense(machine_vocab_size,activation=“softmax”)(s) instead of
output_layer. Using output_layer fixed the error.