Pix2Pix assignment: Model training and test cells succesful but assignment still not accepted

I have completed the test cells, trained the model succesfully and checked the results, which are quite nice. However, when I submit the assignment I get a fail with the following message:

Cell #UNQ_C2. Can’t compile the student’s code. Error: SyntaxError(‘invalid syntax’, (’/tmp/student_solution_cells/cell_8.py’, 36, 14, ’ prediction = disc(fake_images, condition)\n’))

The assignment is working fine, both for the test and for the training and I can´t see the problem. I have tried to restore the notebook and write the same code again. Is keeps working but the result after submitting it is the same

Greetings @Jaime,
hope you are doing fine, can you please provide us your cell code (UNQ_C2 cell to be specific) so we can see what’s wrong with it and help you further?
yours sincerely.

Hello Ramin thanks for the quick answer. Here is the code:

fake_images = gen(condition).to(device = 'cuda')
prediction = disc(fake_images, condition)
ground_truth = torch.ones_like(prediction)
adv_loss = adv_criterion(prediction, ground_truth)
if real != None:
    real = real.to(device = 'cuda')
recon_loss = recon_criterion(fake_images, real)
gen_loss = adv_loss + recon_loss * (lambda_recon)
#### END CODE HERE ####
1 Like

Dear @Jaime
I believe in line 7, I mean this one:

you must pass the “real” as the first parameter and “fake_images” as the second parameter, but you got it reversed.

also, I believe it’s not necessary to pass the “gen” function and “real” to Cuda since it’s defined as default in the cells above, also the if clause in line 5 is not necessary. since it doesn’t impact the code, you can leave it there.

if your problem is sustained, please inform us.

yours sincerely.

I changes the recon_loss order and retired the Cuda sentences and it was finally accepted. Thanks for the answer!

1 Like