paraschopra / abstract-art-neural-network

Generating abstract art through neural networks in PyTorch
https://towardsdatascience.com/making-deep-neural-networks-paint-to-understand-how-they-work-4be0901582ee
43 stars 22 forks source link

NN is not defined #5

Open c7v opened 4 years ago

c7v commented 4 years ago

Thanks for the code!

At my execution, an error is displayed that is associated with the class NN

>>> n,c = gen_new_image(128, 128, save=False, num_neurons=32)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in gen_new_image
NameError: name 'NN' is not defined
c7v commented 4 years ago
 File "<stdin>", line 2

    ^
IndentationError: expected an indented block
>>>     def __init__(self, activation=nn.Tanh, num_neurons=16, num_layers=9):
  File "<stdin>", line 1
    def __init__(self, activation=nn.Tanh, num_neurons=16, num_layers=9):
    ^
IndentationError: unexpected indent
>>>         """
  File "<stdin>", line 1
    """
    ^
IndentationError: unexpected indent
>>>         num_layers must be at least two
  File "<stdin>", line 1
    num_layers must be at least two
    ^
IndentationError: unexpected indent
>>>         """
  File "<stdin>", line 1
    """
    ^
IndentationError: unexpected indent
>>>         super(NN, self).__init__()
  File "<stdin>", line 1
    super(NN, self).__init__()
    ^
IndentationError: unexpected indent
>>>         layers = [nn.Linear(2, num_neurons, bias=True), activation()]
  File "<stdin>", line 1
    layers = [nn.Linear(2, num_neurons, bias=True), activation()]
    ^
IndentationError: unexpected indent
>>>         for _ in range(num_layers - 1):
  File "<stdin>", line 1
    for _ in range(num_layers - 1):
    ^
IndentationError: unexpected indent
>>>             layers += [nn.Linear(num_neurons, num_neurons, bias=False), activation()]
  File "<stdin>", line 1
    layers += [nn.Linear(num_neurons, num_neurons, bias=False), activation()]
    ^
IndentationError: unexpected indent
>>>         layers += [nn.Linear(num_neurons, 3, bias=False), nn.Sigmoid()]
  File "<stdin>", line 1
    layers += [nn.Linear(num_neurons, 3, bias=False), nn.Sigmoid()]
    ^
IndentationError: unexpected indent
>>>         self.layers = nn.Sequential(*layers)
  File "<stdin>", line 1
    self.layers = nn.Sequential(*layers)
    ^
IndentationError: unexpected indent
>>> 
>>>     def forward(self, x):
  File "<stdin>", line 1
    def forward(self, x):
    ^
IndentationError: unexpected indent
>>>         return self.layers(x)
  File "<stdin>", line 1
    return self.layers(x)
    ^
IndentationError: unexpected indent