Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DM_course
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Petra
DM_course
Commits
ec999fa5
Commit
ec999fa5
authored
Feb 14, 2020
by
Petra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
neural nets XOR
parent
6311ffc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
9_neural_nets-4-xor.py
9_neural_nets-4-xor.py
+20
-0
No files found.
9_neural_nets-4-xor.py
0 → 100644
View file @
ec999fa5
from
keras.models
import
Sequential
from
keras.layers.core
import
Dense
,
Dropout
,
Activation
from
keras.optimizers
import
SGD
import
numpy
as
np
X
=
np
.
array
([[
0
,
0
],
[
0
,
1
],
[
1
,
0
],
[
1
,
1
]])
y
=
np
.
array
([[
0
],
[
1
],
[
1
],
[
0
]])
model
=
Sequential
()
model
.
add
(
Dense
(
100
,
input_dim
=
2
))
#model.add(Activation('tanh'))
model
.
add
(
Dense
(
1
))
model
.
add
(
Activation
(
'sigmoid'
))
sgd
=
SGD
(
lr
=
0.1
)
model
.
compile
(
loss
=
'binary_crossentropy'
,
optimizer
=
sgd
)
model
.
fit
(
X
,
y
,
batch_size
=
1
,
nb_epoch
=
1000
)
print
(
model
.
predict_proba
(
X
))
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