C1W1 assignment's code is working fine but I am getting review

Hi,

My code works perfectly, however, I have received a review.

This is the grader’s output but I dont see anything wrong with the code.

Cell #UNQ_C3. Can’t compile the student’s code. Error: SyntaxError(‘invalid syntax’, (’/tmp/student_solution_cells/cell_6.py’, 22, 15, ’ noiseVector=torch.ones(n_samples, z_dim,device=device)\n’))

I am resubmitting with minor changes; I tried with randn as well as torch.normal. The code executes perfectly for both of them.

But I am not sure why I am getting the syntax error.

From my end the entire code is working fine and generating the output as displayed in the notebook.

Please review the code and let me know the actual cause.

Regards,

Gaurang

Hi @Gaurang_Sharma,

The auto-grader can sometimes be touchy, usually when it runs across something it doesn’t expect. This may be a situation where we want to enhance the auto-grader to be more lenient, but let’s start by seeing if we can narrow down the issue and get the auto-grader to accept your code.

A few questions:

Is the line:
noiseVector=torch.ones(n_samples, z_dim,device=device)
within the #### START CODE HERE #### … #### END CODE HERE #### portion of #UNQ_C3?
Do you need that line when you try your randn implementation?
Can you see if you can implement that section without the noiseVector... line?

Hi @Wendy ,

I have submitted up to nine solutions,
The above is one of them.

The below code error was from my first solution, and I tried the same today as well,
Cell #UNQ_C3. Can’t compile the student’s code. Error: SyntaxError(‘invalid syntax’, (’/tmp/student_solution_cells/cell_6.py’, 22, 10, ’ return torch.randn(n_samples, z_dim, device=device)\n’))

I have tried multiple attempts and they all seem to be working.
I even tried various random generation functions; they all worked fine with output.

I am not sure of its further optimization.

I even tried the noise generation function from the 2nd assignment exercise.
Even that is not clear as the submission (which got graded in the 2nd week).

Could you please help me with it?

Regards,
Gaurang

Hmm. So it’s not your implementation. My guess is that something just above this line was inadvertently edited, confusing the auto-grader. It can be very touchy.

I expect it will work if you refresh the assignment and copy in your code changes to the new copy. Instructions for how to refresh your assignment are here: Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera

I’m also happy to take a look if you want to DM me your ipynb file for this assignment.

HI @Wendy,

Thanks a lot, The same code worked after refreshing the workspace.

Regards,
Gaurang