def validation_step(self, batch):
inputs, targets = batch
# Generate predictions
out = self(inputs)
# Calculate loss
loss = nn.CTCLoss(out, targets) # fill this
return {‘val_loss’: loss.detach()}
I get this error in the evaluate step:
ModuleAttributeError: 'CTCLoss' object has no attribute 'detach'
any insight would be helpful. I have tried other loss functions and all throw the same error. My guess is the error is python/user related and not PyTorch related.
Thanks for your help and you are correct. The first code snippet is from the class in Step 3: Create a Linear Regression Model of assignment 2 where the loss function including the detach attribute is defined. The ModuleAttributeError error is thrown later in Step 4: Train the model to fit the data when I call the evaluate function to calculate the loss on the validation.
I have tried F.ctc_loss() as well and get the same error.