This is regarding the customer Dense Layer portion of the course.
I have tried recreating this code for a custome dense layer on my desktop.
For this, I am using Visual Studio code with a Jupyter Notebook and a Python 3.12.3 Kernel.
When I try to run the code recreated I run into two different issues:
The variables are not shown when I try to print the my_dense.variables. It just shows an empty list.
When I try to fit the model with the Xs and Ys, a Type Error is shown saying “Failed to convert elements of (None, 1) to Tensor.”
Why are these errors showing? If the code is the excat same what is the issue?
I am leaving the link to the training lab with the code I am trying to recreate.
The code is the exact same but done in VS Code.
I would like to see my error to prevent this in the future.
running assignment code locally require many modifications as well as similar modules version which were used in the coursera provided environment. One would also require to have metadata(utils file related to the assignment)
Also as far as I remember the course you are talking about were not run down in the python version you are working.
Aside from what @Deepti_Prasad mentioned. You need to check your implementation for issue. Double-check that your layer’s build method is defining weights based on the input shape and that your Xs and Ys are correctly preprocessed. Also, check your TensorFlow library version and availability of the required scripts, too.
Hope it helps! Feel free to ask if you need further assistance.
I checked the environment from the lab.
It is a Jupyter notebook using Python 3.
The code is explained using Google Colab, and the Lab is different it is a jupyter notebook with python 3.
Both in the video and the lab the code runs smoothly.
Locally in VS Code the code won’t run as desired, I also recreated the code in my own Colab and it won’t run, it shows the same issues.
I checked everything and the code is the exact same as presented in the course.
Same environment, same kernel and the code won’t run when recreated.
The TensorFlow version for me is version 2.18.0, so it should be up to par with the one from the exercise.
Also I tried defining the data types as np.float32 and tf.float32 and the same type error occurs. I just want to make sure I can recreate a model like this in the future and I don’t understand why I run into these issues.
Even with help of chatGPT the same errors occur, I change the initializer to RandomNormal() and it shows errors aswell.
The predict model shows an empty list and when I try to fit the model it shows a type error.
Do you need a screenshot of the code or the errors? I honestly don’t understand why the code won’t run as shown in the course.