You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get this error
TypeError: tanh() missing 1 required positional arguments: "input"
I get the same error when I replace relu in the forward section too.
I can see it has an input but I don't know what variable that should be or how to provide it when calling the model.
We did some other functions ourselves in the course but I don't remember seeing this as a problem, relu for example.
I get a good result not using tamh anyway, but I do want to know how to write my own functions and be able to use them in a model.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
(short comment: the posting removes the indentation)
I got this from the documentation on tanh
def tanh(z):
return (torch.exp(z) - torch.exp(-z)) / (torch.exp(z) + torch.exp(-z))
The original line in the doc was nn.exp but I got numpy array errors then which is a pain at that point in the code. So I tried torch.exp
I put this in a cell.
Then in the model def I try using it.
class MoonModelV1(nn.Module):
def init(self):
super().init()
#out_features = 5 expands to have nore nodes, upscale
self.layer_1 = nn.Linear(in_features=NUM_FEATURES, out_features=10)
self.layer_2 = nn.Linear(in_features=10, out_features=10)
self.layer_3 = nn.Linear(in_features = 10, out_features = NUM_CLASSES)
self.relu = nn.ReLU()
self.tanh = torch.tanh()
I get this error
TypeError: tanh() missing 1 required positional arguments: "input"
I get the same error when I replace relu in the forward section too.
I can see it has an input but I don't know what variable that should be or how to provide it when calling the model.
We did some other functions ourselves in the course but I don't remember seeing this as a problem, relu for example.
I get a good result not using tamh anyway, but I do want to know how to write my own functions and be able to use them in a model.
Beta Was this translation helpful? Give feedback.
All reactions