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!

3 Likes

SOLVED.

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

1 Like

How did you fix the above issue?

1 Like

Hi @Yang_Kim,

Ensure that the data types are tensors

1 Like

How to fix this problem?

1 Like

@Jelena_Jevremovic, this is an issue where the grader has an older version of PyTorch and the graders version of torch.cat can’t handle different types, so you need to make sure you need to make sure both values you pass to it are floats.

Here’s a thread with more details

1 Like