Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
ML725
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
SHREYANSH JAIN
ML725
Commits
2c147717
Commit
2c147717
authored
Oct 07, 2019
by
SHREYANSH JAIN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autograder 28
parent
10f7bda2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
Assignment2/__pycache__/main.cpython-36.pyc
Assignment2/__pycache__/main.cpython-36.pyc
+0
-0
Assignment2/__pycache__/nn.cpython-36.pyc
Assignment2/__pycache__/nn.cpython-36.pyc
+0
-0
Assignment2/main.py
Assignment2/main.py
+2
-2
Assignment2/nn.py
Assignment2/nn.py
+6
-6
No files found.
Assignment2/__pycache__/main.cpython-36.pyc
View file @
2c147717
No preview for this file type
Assignment2/__pycache__/nn.cpython-36.pyc
View file @
2c147717
No preview for this file type
Assignment2/main.py
View file @
2c147717
...
...
@@ -14,7 +14,7 @@ def taskXor():
# raise NotImplementedError
###############################################
YTrain
,
YVal
,
YTest
=
np
.
array
([
int
(
i
[
1
]
==
1
)
for
i
in
YTrain
])
.
reshape
((
-
1
,
1
)),
np
.
array
([
int
(
i
[
1
]
==
1
)
for
i
in
YVal
])
.
reshape
((
-
1
,
1
)),
np
.
array
([
int
(
i
[
1
]
==
1
)
for
i
in
YTest
])
.
reshape
((
-
1
,
1
))
lr
,
batchSize
,
epochs
=
0.
2
,
50
,
10
lr
,
batchSize
,
epochs
=
0.
01
,
50
,
10
nn1
=
nn
.
NeuralNetwork
(
lr
,
batchSize
,
epochs
)
# Add layers to neural network corresponding to inputs and outputs of given data
input_layer
=
XTrain
.
shape
[
1
]
...
...
@@ -48,7 +48,7 @@ def preprocessMnist(X):
def
taskMnist
():
XTrain
,
YTrain
,
XVal
,
YVal
,
XTest
,
_
=
loadMnist
()
# Create a NeuralNetwork object 'nn1' as follows with optimal parameters. For parameter definition, refer to py file.
lr
,
batchSize
,
epochs
=
0.
2
,
256
,
50
lr
,
batchSize
,
epochs
=
0.
01
,
256
,
50
nn1
=
nn
.
NeuralNetwork
(
lr
,
batchSize
,
epochs
)
# Add layers to neural network corresponding to inputs and outputs of given data
input_layer
=
XTrain
.
shape
[
1
]
...
...
Assignment2/nn.py
View file @
2c147717
...
...
@@ -131,7 +131,7 @@ class FullyConnectedLayer:
# TASK 1a (Marks 0) - YOUR CODE HERE
# raise NotImplementedError
self
.
weights
=
np
.
random
.
randn
(
in_nodes
,
out_nodes
)
/
np
.
sqrt
(
in_nodes
)
self
.
biases
=
np
.
zeros
(
(
out_nodes
,
1
)
)
self
.
biases
=
np
.
zeros
(
out_nodes
)
###############################################
# NOTE: You must NOT change the above code but you can add extra variables if necessary
...
...
@@ -207,12 +207,12 @@ class FullyConnectedLayer:
###############################################
# TASK 1d (Marks 4) - YOUR CODE HERE
if
self
.
activation
==
'relu'
:
self
.
data
=
X
@
self
.
weights
+
self
.
biases
.
T
return
self
.
relu_of_X
(
self
.
data
)
self
.
data
=
self
.
relu_of_X
(
np
.
add
(
X
@
self
.
weights
,
self
.
biases
))
return
self
.
data
raise
NotImplementedError
elif
self
.
activation
==
'softmax'
:
self
.
data
=
X
@
self
.
weights
+
self
.
biases
.
T
return
self
.
softmax_of_X
(
self
.
data
)
self
.
data
=
self
.
softmax_of_X
(
np
.
add
(
X
@
self
.
weights
,
self
.
biases
))
return
self
.
data
raise
NotImplementedError
else
:
print
(
"ERROR: Incorrect activation specified: "
+
self
.
activation
)
...
...
@@ -239,7 +239,7 @@ class FullyConnectedLayer:
print
(
"ERROR: Incorrect activation specified: "
+
self
.
activation
)
exit
()
self
.
weightsGrad
=
(
activation_prev
.
T
@
inp_delta
)
/
delta
.
shape
[
0
]
self
.
biasesGrad
=
np
.
average
(
inp_delta
,
axis
=
0
)
.
reshape
((
delta
.
shape
[
1
],
-
1
))
self
.
biasesGrad
=
np
.
average
(
inp_delta
,
axis
=
0
)
new_delta
=
inp_delta
@
self
.
weights
.
T
return
new_delta
###############################################
...
...
Write
Preview
Markdown
is supported
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