Pytorch Not implement Error when running Training

username: brains93
cooked: <p>Hey all,</p>
<p>I am doing some stuff for uni, I have to build a basic neural net based of the dataset provided to us which is a series of opcodes and the net has to determine which is malware and which is clean based on a predefined tag.</p>
<p>There I am getting is when I run the code to start the train net I get a not implmeneted error. from googling most people reckon that it is an indenting issue but I have typed and retpyed it to check for this and I am still getting the error.</p>
<pre><code class="lang-auto">model.train() 
for data in dataset_train:
    optimizer.zero_grad()
    output = model(data)
    loss = criterion(output)
    loss.backward()
    optimizer.step()
    train_loss += loss.item() * data.size(0)

model.eval() 
for data in dataset_test:
    output = model(data)
    loss = criterion(output, data)
    valid_loss += loss.item() * data.size(0)

train_loss = train_loss / len(train_loader.sampler)
valid_loss = valid_loss / len(valid_loader.sampler)

print('Epoch: {} \tTraining Loss: {:.6f} \tValidation Loss: {:.6f}'.format(
    epoch + 1,
    train_loss,
))

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
&lt;ipython-input-32-302975be982c&gt; in &lt;module&gt;
      2 for data in sampleset:
      3     optimizer.zero_grad()
----&gt; 4     output = model(data)
      5     loss = criterion(output)
      6     loss.backward()

D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
    725             result = self._slow_forward(*input, **kwargs)
    726         else:
--&gt; 727             result = self.forward(*input, **kwargs)
    728         for hook in itertools.chain(
    729                 _global_forward_hooks.values(),

D:\Anaconda3\lib\site-packages\torch\nn\modules\module.py in _forward_unimplemented(self, *input)
    173         registered hooks while the latter silently ignores them.
    174     """
--&gt; 175     raise NotImplementedError
    176 
    177 

NotImplementedError: 
</code></pre>
<p>As I said I have a feeling that maybe I have not imported the data correctly, the code to pull in the opcodes into a list is done for us already we just have to prep it for the neural net. I done that use the code below.</p>
<pre><code class="lang-auto">sampleset = []
sampleset.extend(malware)
sampleset.extend(clean)

sampleset = torch.LongTensor(sampleset)

dataset_train = torch.utils.data.DataLoader(sampleset, batch_size=1000, shuffle=True)
dataset_test = torch.utils.data.DataLoader(sampleset, batch_size=500, shuffle=True)
</code></pre>
<p>Any advice or pointers would be appreciated</p>

username: ptrblck
cooked: <p>If the indentation is correct, make sure the spelling is also right as others were also running into it by typing e.g. <code>forwrad</code> instead of <code>forward</code>.</p>

username: brains93
cooked: <p>I have went through and I cant see anything that is misspelt though I could be being blind<br>
here is the forward function in case there is something wrong in there<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/a/0a369c0ae665ef44e02d87e66a833e6a39ff05b2.png" data-download-href="https://discuss.pytorch.org/uploads/default/0a369c0ae665ef44e02d87e66a833e6a39ff05b2" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/0/a/0a369c0ae665ef44e02d87e66a833e6a39ff05b2.png" alt="image" data-base62-sha1="1slM3vJYNrZO0x2gIyWmv8FsNqO" width="690" height="322" data-dominant-color="F5F5F5"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1094×512 24.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: ptrblck
cooked: <p>Could you post the code by wrapping it into three backticks ```, please?<br>
In your current cell it seems that <code>def forward</code> doesn’t have any indentation level and is thus a global method.</p>

username: brains93
cooked: <p>AH yeah I was being stupid. going to chalk it down to not being used to Jupyter notebook… I had the net defined in the box above so when I put the forward function in the next box it wasn’t indented and I just started reading them as two separate functions!</p>
<p>error 406 replace user</p>
<p>Cheers for the help <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>