C1 W4 Assignment errors

Dear all,

Can please someone help me with this error? It appears on both my laptops on several browsers. I have just copied the lines from the lab to create the solution an it is not working.

here is the portion of the message

Uncaught Error: Failed to compile fragment shader.
at VIe (tfjs@latest:17:1087430)
at aSe (tfjs@latest:17:1146462)
at tfjs@latest:17:1201609
at s.value (tfjs@latest:17:1202459)
at s.value (tfjs@latest:17:1201571)
at fAe (tfjs@latest:17:1275305)
at Object.dAe [as kernelFunc] (tfjs@latest:17:1276131)
at n (tfjs@latest:17:222081)
at tfjs@latest:17:223012
at e.value (tfjs@latest:17:220344)
rpsls.html:1 WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
tfjs@latest:17 WebGL: INVALID_OPERATION: attachShader: object does not belong to this context
(anonymous) @ tfjs@latest:17
tfjs@latest:17 The program must contain objects to form both a vertex and fragment shader.

I am attaching a screenshot

I should mention that this always appear during image capture and sometimes while collecting spock and sometimes while collecting lizard image samples.

I cannot even train the model in a few words

are you trying to state you copied the codes from the ungraded lab and run the assignment note book on the browser??

I hope you using bracket to do these assignment.

there seems to be error in your code.

You can DM me or @Jamal022 (mentor for this course) your notebook. We can have a look if you are doing it right. But first make sure

you have followed the following the steps.

  1. Kept all the files required to the assignment in your local drive as one needs to use browser as console for which Jupyter is used to know your local python http server.

  2. If point 1, is followed. Then make sure you have not just copied the codes from ungraded lab but written the codes in bracket (note not browser) as the ungraded lab only defines rock paper scissor but the assignment has extra two samples of lizard and Spock samples.

  3. I don’t think you haven’t taken still samples images as you have this error.

Click on my name, then message to send the assignment. Kindly rename your file with your name and then send.


Hello again,

No I am not using brackets and why should I? The code is being written differently in VS Code?

The code run without issue for the first time that I made the attempt to submit my answer and then it stopped working without any obvious reason.

I copied the code from he link that is in the assignment I am not sure where I could find the upgraded assignment.

In any case the issue disappeared and I managed to submit the answer.

Just a last comment and question. How could you came up to the conclusion that the code i wrote had an issue? I copied the lines for the similar lab changing the output to 5, I copied the optimizer also from the lab and added the case lines for the 5th class… Ridiculously easy…

Have you cleared the assignment?

The error you shared usually happen if there is discrepancies in tf version sometimes.

Happy to know that you copied codes from which ever lab you used. All the best!!!

I mentioned ungraded lab assignment which is there in that week.

We are suppose to use bracket to do these assignment.

You can do whatever you want, copy-paste, I am not here to judge you. Sometimes copying creates error and also not the right way to do or learn these assignment. you can always refer the codes. I suppose when you are mentioning copying, you are mentioning referring which is okay.

At the end, everything is your personal choice.

With your last comment I come to understanding you have cleared the assignment.


Hello again!

Everything is OK, thank you very much for you interest and replies!

I got the same error. I have run that lab beyond 10 times and got the same error.

I am using the last version available of the tf library and the latest Edge update.

Hey @JuanPeguero,

Did you follow Deepti’s steps?

Hi @Jamal022. Yes I follow Deepti’s steps.

I would try in another pc with different tf version. That error is related to the Webcam handle. I ran the one from ungraded lab with just the 3 options and got the same error after 200 img capture.

Hello Juan,

Please check your DM Juan.


I got a fresh copy of the assigment and start over againg. Now I am able to get all the img capture and Train the model. But just after the Traing is done! message, got he error:
rpsls.html:1 WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
tfjs@latest:17 Uncaught (in promise) Error: Failed to compile fragment shader.
at VIe (tfjs@latest:17:1087165)
at aSe (tfjs@latest:17:1146197)
at tfjs@latest:17:1201344
at s.value (tfjs@latest:17:1202194)
at s.value (tfjs@latest:17:1201306)
at TRe (tfjs@latest:17:1346378)
at Object.uOe [as kernelFunc] (tfjs@latest:17:1386231)
at n (tfjs@latest:17:222081)
at tfjs@latest:17:223012
at e.value (tfjs@latest:17:220344)

Here again.
Just to let you know that I finally could do the assignment. I changed the pc and also had to change the browser.