Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HPC_Machine_Learning_TP_Final
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
maxime.clercq
HPC_Machine_Learning_TP_Final
Commits
42174698
Commit
42174698
authored
5 years ago
by
Maxxhim
Browse files
Options
Downloads
Patches
Plain Diff
add Substraction
parent
b47b2617
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
functions.py
+5
-5
5 additions, 5 deletions
functions.py
variable.py
+2
-2
2 additions, 2 deletions
variable.py
with
7 additions
and
7 deletions
functions.py
+
5
−
5
View file @
42174698
...
@@ -52,21 +52,21 @@ class Sub(_Function):
...
@@ -52,21 +52,21 @@ class Sub(_Function):
def
__init__
(
self
,
x
,
y
):
def
__init__
(
self
,
x
,
y
):
super
().
__init__
(
"
Sub
"
,
x
,
y
)
super
().
__init__
(
"
Sub
"
,
x
,
y
)
#######################################################################
#######################################################################
#
TODO:
Implement the forward pass and put the result in self.result.
# Implement the forward pass and put the result in self.result.
# The notbook provide you the formulas for this operation.
# The notbook provide you the formulas for this operation.
#######################################################################
#######################################################################
self
.
result
=
None
self
.
result
=
x
.
data
-
y
.
data
#######################################################################
#######################################################################
# --------------------------- END OF YOUR CODE ------------------------
# --------------------------- END OF YOUR CODE ------------------------
#######################################################################
#######################################################################
def
_backward
(
self
,
grad
):
def
_backward
(
self
,
grad
):
#######################################################################
#######################################################################
#
TODO:
Implement the derivative dx for this opetation and add the
# Implement the derivative dx for this opetation and add the
# result of the chain rule on self.dx.
# result of the chain rule on self.dx.
#######################################################################
#######################################################################
self
.
dx
=
None
self
.
dx
=
grad
self
.
dy
=
None
self
.
dy
=
-
grad
#######################################################################
#######################################################################
# --------------------------- END OF YOUR CODE ------------------------
# --------------------------- END OF YOUR CODE ------------------------
#######################################################################
#######################################################################
...
...
This diff is collapsed.
Click to expand it.
variable.py
+
2
−
2
View file @
42174698
...
@@ -169,9 +169,9 @@ class Variable:
...
@@ -169,9 +169,9 @@ class Variable:
children
=
[]
children
=
[]
if
not
len
(
children
):
if
not
len
(
children
):
#######################################################################
#######################################################################
#
TODO:
Call the backward of the operation that has build this Variable
# Call the backward of the operation that has build this Variable
#######################################################################
#######################################################################
pass
self
.
grad_fn
.
backward
(
self
.
grad
,
retain_graph
)
#######################################################################
#######################################################################
# --------------------------- END OF YOUR CODE ------------------------
# --------------------------- END OF YOUR CODE ------------------------
#######################################################################
#######################################################################
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment