Error in first gan

Hi everyone
when I run the code from Coursera week 1 “your new GAN” this error appears?

PS D:\python\all.py> & “C:/Program Files/Python39/python.exe” d:/python/all.py/me.py
Traceback (most recent call last):
File “d:\python\all.py\me.py”, line 63, in
test_gen_block(25,12)
File “d:\python\all.py\me.py”, line 48, in test_gen_block
block = get_generator_block(in_features, out_features)
File “d:\python\all.py\me.py”, line 40, in get_generator_block
nn.Linear(None, None),
File “C:\Users\Active\AppData\Roaming\Python\Python39\site-packages\torch\nn\modules\linear.py”, line 96, in init
self.weight = Parameter(torch.empty((out_features, in_features), **factory_kwargs))
TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of:

  • (tuple of ints size, *, tuple of names names, torch.memory_format memory_format, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
  • (tuple of ints size, *, torch.memory_format memory_format, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool
    pin_memory, bool requires_grad)
    should I change any thing or not?

This initialization:

nn.Linear(None, None)

is wrong as you are supposed to set values for in_features and out_features and cannot pass None as arguments.
Are you sure you should just execute the code or are you supposed to fill in the missing pieces?

1 Like

yes, thank you
I got it