I’m working on the graded assignment in Week 2(Programming Assignment: Forecasting Using Neural Networks).
Here’s my implementation of create_model:
# GRADED FUNCTION: create_model
def create_model(window_size):
# code removed by mentor
return model
When I test with:
example_batch = train_dataset.take(1)
model = create_model(WINDOW_SIZE)
try:
model.evaluate(example_batch, verbose=False)
except:
print("Your model is not compatible with the dataset.")
I still get:
Your model is not compatible with the dataset you defined earlier.
Question:
Is the issue in the model definition or could it be in how I built train_dataset with windowed_dataset? What’s the correct expected input/output shape for this assignment?
Model definition looks good. Please check the shapes of the windowed dataset. Each row of the input dataset consists of 10 input features and 1 output feature. creating a temporary jupyter notebook cell and invoking model.evaluate(example_batch, verbose=False) will help figure out the problem.
is this the complete output you got when run test cell after create model grade function codes?
Also remember the model is using the dataset fromyout previous grade function, where you need to check if the slicing is done in appropriate windows. While slicing, drop_reminder is an important parameter to consider
drop_remainder (Optional.) A tf.bool scalar tf.Tensor, representing whether the last batch should be dropped in the case it has fewer than batch_size elements; the default behavior is not to drop the smaller batch.
make sure you are using correct tensorflow dataset function recall from series to create your dataset
Further make sure when you are splitting dataset into labels and features, you used the correct variable recall to do the splitting.
Let us know if you are still stuck, at which time one of us need to review your codes for previous grade function windowed_dataset
In fact, this is the same error I got right after the message: "Your model is not compatible with the dataset you defined earlier. Check that the loss function and last layer are compatible with one another."
So the real issue is that model is not being recognized in that cell, even though I defined it inside the create_model function.
yeah actually i got this error after the message “Your model is not compatible with the dataset you defined earlier. Check that the loss function and last layer are compatible with one another.” and unfortunately , i tried all you said before but nothing changed
Cell In[49], line 5
model.evaluate(example_batch, verbose=False
^
SyntaxError: incomplete input
The output of window_dataset is like the expected output :
batch_of_features has type: <class 'tensorflow.python.framework.ops.EagerTensor'>
batch_of_labels has type: <class 'tensorflow.python.framework.ops.EagerTensor'>
batch_of_features has shape: (32, 10)
batch_of_labels has shape: (32,)
First element in batch_of_features is equal to first 10 elements in the series: True
batch_of_labels is equal to the first 32 values after the window_lenght of 10): True
am sorry for the brackets , and the code you gave me worked and i got ‘All tests passed!‘ but still Failed test case: Got a wrong value for the MSE loss. Expected: MSE<30, but got: 32.009769439697266.
also on Check the parameter count against a reference solution
predictions have shape: (32, 1)
Expected output:
predictions have shape: (NUM_BATCHES, 1)
Where NUM_BATCHES is the number of batches you have set to your dataset.