educative.io

Small typo un D.train(generate_random(), torch.FloatTensor([0.0])) # shouldn't this line give an error?

in the code below in the line D.train(generate_random(), torch.FloatTensor([0.0])) # shouldn’t this line give an error?

import torch
import torch.nn as nn

def generate_random(size):
random_data = torch.rand(size)
return random_data

print(“Random noise pattern:”, generate_random(4))

D = Discriminator()

for i in range(10000):
# real data
D.train(generate_real(), torch.FloatTensor([1.0]))
# fake data
D.train(generate_random(), torch.FloatTensor([0.0])) # shouldn’t this line give an error?
pass

generate_random() missing 1 required positional argument: ‘size’

Hello @Yogesh_More,
Yes, you are right this would give an error. However, I think you took this line from the code snippet which was not executable, and if you go look at the executable code, this function does have a size passed as shown below.