Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mira Arabi Haddad
DL Mini Projects Group M
Commits
c0bc7811
Commit
c0bc7811
authored
Dec 17, 2021
by
Mira Arabi Haddad
Browse files
GROUPWORK_Fixed tanh, Finalize modules.py
parent
8c8f2b85
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2/modules.py
View file @
c0bc7811
...
...
@@ -169,7 +169,8 @@ class Tanh(Module):
def
forward
(
self
,
input
):
self
.
x
=
input
self
.
x
=
torch
.
tanh
(
self
.
x
)
# (self.x.exp() - self.x.mul(-1).exp()) / (self.x.exp() + self.x.mul(-1).exp())
# tanh = (e^x - e^(-x)) / (e^x + e^(-x))
self
.
x
=
(
self
.
x
.
exp
()
-
self
.
x
.
mul
(
-
1
).
exp
())
/
(
self
.
x
.
exp
()
+
self
.
x
.
mul
(
-
1
).
exp
())
return
self
.
x
def
backward
(
self
,
gradwrtoutput
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment