Alpaca_model problem

Okay, officially stumped. I am getting the error:

Expected value
[‘InputLayer’, [(None, 160, 160, 3)], 0]
does not match the input value:
[‘InputLayer’, [(1, 160, 160, 3)], 0]

my data_augmentation function is what is creating the shape:
[‘InputLayer’, [(1, 160, 160, 3)], 0]

even though it has passed unit tests previously. I do not see how to change that data_augmentation function to fix the problem. I don’t want to violate policy by posting code, please advise.

1 Like

The first dimension there is the “samples” dimension. When we define a model, the point is that it should be able to handle any number of samples as the input. We specify the other dimensions, meaning that each sample is a 160 x 160 x 3 RGB image.

You must have done something to hard-wire the number of samples. Please take another look at the code with that idea in mind. Also note that the invocation of data augmentation is not the first thing after defining the base model, at least the way I wrote that code. I used tf.keras.Input to define the input layer. Don’t ignore the directions they give you in the comments there, but maybe there is some ambiguity in how to implement them. :nerd_face:

1 Like

Thanks for the quick response! I wasn’t hard coding anything and I was using tf.keras.Input so on a whim and a prayer, I restarted the kernel and re-ran and it passed the test. So… I’m not sure. But all is happy now.

1 Like

Glad to hear things are ok now. That means your code was already correct, but you weren’t running the code you were looking at. If you type new code in a function cell and then call the function again, it does nothing: it just runs the old code. You actually have to click “Shift-Enter” directly on the modified cell for the new code to take effect. Now that you know how this works, you can easily prove that what I am saying is true:

Find a function that already works and deliberately break it, e.g. by multiplying the return value by *2. Now run the test cell for that function and the tests still pass, right?

Now click “Shift-Enter” on the newly broken code cell and run the test again. Kaboom!

Another way to get things back in sync is what you did:

Kernel → Restart and Clear Output
Cell → Run All

1 Like