Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Images classification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Saidi Aya
Images classification
Commits
b1739e66
Commit
b1739e66
authored
Nov 6, 2022
by
Saidi Aya
Browse files
Options
Downloads
Patches
Plain Diff
Create mlp.py
parent
b4689a40
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mlp.py
+21
-0
21 additions, 0 deletions
mlp.py
with
21 additions
and
0 deletions
mlp.py
0 → 100644
+
21
−
0
View file @
b1739e66
import
numpy
as
np
#We are using the segmoid activation function
def
segmoid
(
x
):
return
1
/
(
1
+
np
.
exp
(
-
x
))
#We will also need the derivation function to instore the gradient
def
derivation
(
x
):
deriv_segmoid
=
segmoid
(
x
)
*
(
1
-
segmoid
(
x
))
return
deriv_segmoid
def
learn_once_mse
(
w1
,
b1
,
w2
,
b2
,
data
,
targets
,
learning_rate
):
# This function performs one gradient descent step
# w1, b1, w2 and b2 -- the weights and biases of the network,
# data -- a matrix of shape (batch_size x d_in)
# targets -- a matrix of shape (batch_size x d_out)
# learning_rate -- the learning rate
A0
=
data
A1
=
segmoid
(
np
.
matmul
(
A0
,
w1
)
+
b1
)
A2
=
segmoid
(
np
.
matmul
(
A1
,
w2
)
+
b2
)
#Let calculate the partial derivates
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