FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorFlow.NET/src/python/xor_keras.py at master · dev-exi/TensorFlow.NET · GitHub
dev-exi
/
TensorFlow.NET
Public
forked from
SciSharp/TensorFlow.NET
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TensorFlow.NET
/
src
/
python
/
xor_keras.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (21 loc) · 741 Bytes
Breadcrumbs
TensorFlow.NET
/
src
/
python
/
xor_keras.py
Copy path
File metadata and controls
24 lines (21 loc) · 741 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import
os
import
numpy
as
np
import
tensorflow
as
tf
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
"-1"
print
(
tf
.
__version__
)
# https://playground.tensorflow.org/
# tf.compat.v1.enable_eager_execution()
# tf.debugging.set_log_device_placement(True);
tf
.
config
.
run_functions_eagerly
(
True
)
x
=
np
.
array
([[
0
,
0
], [
0
,
1
], [
1
,
0
], [
1
,
1
]])
y
=
np
.
array
([[
0
], [
1
], [
1
], [
0
] ])
model
=
tf
.
keras
.
Sequential
()
model
.
add
(
tf
.
keras
.
Input
(
2
))
model
.
add
(
tf
.
keras
.
layers
.
Dense
(
32
,
"relu"
))
model
.
add
(
tf
.
keras
.
layers
.
Dense
(
1
,
"sigmoid"
))
model
.
compile
(
optimizer
=
tf
.
keras
.
optimizers
.
Adam
(),
loss
=
tf
.
keras
.
losses
.
MeanSquaredError
(),
metrics
=
[
"accuracy"
])
model
.
fit
(
x
,
y
,
1
,
100
)
result
=
model
.
evaluate
(
x
,
y
)
print
(
model
.
predict
(
x
,
4
))
Back
|
FazBrowse Home
|
New Git URL