Hi Machine Learing Community,
For the C2W2(module 2 for advanced machine learning specialization) multi class handwritten digit recognition lab, when I run the model it gives different plot each time even if I have set the seed. I was wondering if anyone in here had faced the same problem and got the solution. Would be much help if you could share how you got step up from here?
Try to do a clean run from the menu bar at the top your notebook:
- select kernel tab → Restart kernel and clear all output
- select cell tab → Run all above ( place your current cell just after plotting the loss history)
Hello @ramubhandari158,
@Kic’s way will certainly do, but even without restarting the kernel, on Coursera’s assignment environment, I could also reproduce the same “Loss plot” each time I run each and every code cell in sequence from the cell for exercise 2 to the cell for calling plot_loss_tf(history)
that makes the loss plot.
If you do exactly the same as what I did, are you able to get the same loss plot?
Cheers,
Raymond
Hi @rmwkwok,
It works perfectly fine in Coursera’s assignment environment and labs. I got the same plot every time but the issue is when I use my own jupyter lab. Have a great day.
Thank you,
Ramu Bhandari
Hi @Kic,
Thank you so much for you instructions. But I am still unable to figure it out when I use my own jupyter environment.
Best,
Ramu Bhandari
Hello @ramubhandari158,
Forget about the plot and the training, and then just focus on the exercise 2 cell which includes the line for seed-setting and instantiation of model
. Now, after you instantiate model
, and then if you print model.layers[0].weights
you will see the trainable weights for the first layer.
Do the values in the weights the same every time you re-instantiate the model?
Hi @rmwkwok,
Weights are changing every time even if I set seed as 1234. I tried everything suggested by ai. Same thing happened after c2w3 lab 1 as well. Now, this is my serious issue.
Thanks,
Ramu Bhandari
Hello, @ramubhandari158,
You might try to replace the seed-setting line with the following function:
By the way, @ramubhandari158, even though you are working on a course lab, since it is on your local environment instead of Coursera, we actually don’t have the resources to support that. For example, with only an observation from you, we can’t just know what’s the key difference between the settings in your computer and Cousera and which line of the code has problem.
I really recommend you to try the stackoverflow approach - by asking question with a minimal reproducible example (MRE). This means you will need to investigate every step of the code, single out the first problematic step, then make a MRE of that for your readers.
For example, now you know that the weight initialization step is the first problematic step because without the same set of weights, we couldn’t hope the subsequent step to be the same.
Singling out the problematic step is a very important skill, and that result will help you ask a concise question and perform a search (Google example), and my search gave me this answer.
Our support for the course is limited. Anything beyond would better stick with the best practice of how to ask a question on an internet community like stackoverflow. Since you are exploring tensorflow in your own way (not on Coursera), I recommend you to stick to those practices. While we shouldn’t share course material without consent, with your own MRE written by you, you may actually just ask questions anywhere, including stackoverflow, for a broader audience.
I think this will be my last reply to this topic. Good luck
Cheers,
Raymond