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
f7e49dd5
Commit
f7e49dd5
authored
5 years ago
by
Maxxhim
Browse files
Options
Downloads
Patches
Plain Diff
add matrix multiplication
parent
69b46d09
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
functions.py
+12
-12
12 additions, 12 deletions
functions.py
with
12 additions
and
12 deletions
functions.py
+
12
−
12
View file @
f7e49dd5
...
...
@@ -143,8 +143,8 @@ class MatMul(_Function):
# TODO: Implement the derivative dx for this opetation and add the
# result of the chain rule on self.dx.
#######################################################################
self
.
dx
=
None
self
.
dy
=
None
self
.
dx
=
np
.
add
(
self
.
x
.
data
.
transpose
(),
self
.
y
.
data
)
self
.
dy
=
np
.
add
(
self
.
x
.
data
,
self
.
y
.
data
.
transpose
())
#######################################################################
# --------------------------- END OF YOUR CODE ------------------------
#######################################################################
...
...
@@ -156,7 +156,7 @@ class Exp(_Function):
def
__init__
(
self
,
x
):
super
().
__init__
(
"
Exp
"
,
x
)
#######################################################################
#
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.
#######################################################################
self
.
result
=
np
.
exp
(
self
.
x
.
data
)
...
...
@@ -166,7 +166,7 @@ class Exp(_Function):
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.
#######################################################################
self
.
dx
=
grad
*
np
.
exp
(
self
.
x
.
data
)
...
...
@@ -181,7 +181,7 @@ class Log(_Function):
def
__init__
(
self
,
x
):
super
().
__init__
(
"
Exp
"
,
x
)
#######################################################################
#
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.
#######################################################################
self
.
result
=
np
.
log
(
self
.
x
.
data
)
...
...
@@ -191,7 +191,7 @@ class Log(_Function):
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.
#######################################################################
self
.
dx
=
grad
*
1
/
(
self
.
x
.
data
)
...
...
@@ -206,7 +206,7 @@ class Sin(_Function):
def
__init__
(
self
,
x
):
super
().
__init__
(
"
Sin
"
,
x
)
#######################################################################
#
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.
#######################################################################
self
.
result
=
np
.
sin
(
self
.
x
.
data
)
...
...
@@ -216,7 +216,7 @@ class Sin(_Function):
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.
#######################################################################
self
.
dx
=
grad
*
np
.
cos
(
self
.
x
.
data
)
...
...
@@ -231,7 +231,7 @@ class Cos(_Function):
def
__init__
(
self
,
x
):
super
().
__init__
(
"
Cos
"
,
x
)
#######################################################################
#
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.
#######################################################################
self
.
result
=
np
.
cos
(
self
.
x
.
data
)
...
...
@@ -241,7 +241,7 @@ class Cos(_Function):
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.
#######################################################################
self
.
dx
=
grad
*
(
-
np
.
sin
(
self
.
x
.
data
))
...
...
@@ -256,7 +256,7 @@ class Tan(_Function):
def
__init__
(
self
,
x
):
super
().
__init__
(
"
Tan
"
,
x
)
#######################################################################
#
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.
#######################################################################
self
.
result
=
np
.
tan
(
self
.
x
.
data
)
...
...
@@ -266,7 +266,7 @@ class Tan(_Function):
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.
#######################################################################
self
.
dx
=
grad
*
(
1
/
np
.
square
(
np
.
cos
(
self
.
x
.
data
)))
...
...
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