C1W4A_Build_a_Conditional_GAN Assignment Grader Problem

I get the following error with cell 7 during grading only, even thought the notebook works fine otherwise, and there is no error(or assertion error) when I am actually running the cell in notebook. Here is the error:

Cell #7. Can't compile the student's code. Error: RuntimeError("Expected object of scalar type Long but got scalar type Float for sequence element 1 in sequence argument at position #1 'tensors'",)

My code is:

UNQ_C2 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
GRADED FUNCTION: combine_vectors
def combine_vectors(x, y):
    '''
    Function for combining two vectors with shapes (n_samples, ?) and (n_samples, ?).
    Parameters:
      x: (n_samples, ?) the first vector. 
        In this assignment, this will be the noise vector of shape (n_samples, z_dim), 
        but you shouldn't need to know the second dimension's size.
      y: (n_samples, ?) the second vector.
        Once again, in this assignment this will be the one-hot class vector 
        with the shape (n_samples, n_classes), but you shouldn't assume this in your code.
    '''
    # Note: Make sure this function outputs a float no matter what inputs it receives
    #### START CODE HERE ####
    combined = torch.cat([x,y],dim=1).float()
    #### END CODE HERE ####
    return combined

If I do not type cast the combined tensor to float, I get assertion error in tester cell below this cell, that is why I type casted it to float.

Iā€™d love any help!

2 Likes

SOLVED.

Was not type casting tensors to float properly in training loop.

How did you fix the above issue?

Hi @Yang_Kim,

Ensure that the data types are tensors