Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F64213521
test.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, May 25, 09:11
Size
1 KB
Mime Type
text/x-python
Expires
Mon, May 27, 09:11 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17868499
Attached To
rMLECMO Machine Learning ECMO
test.py
View Options
import
tensorflow
as
tf
from
tensorflow
import
keras
import
numpy
as
np
nb
=
1000
((
train_input
,
train_target
),
(
test_input
,
test_target
))
=
tf
.
keras
.
datasets
.
mnist
.
load_data
()
train_input
=
train_input
.
reshape
((
60000
,
28
,
28
,
1
))
test_input
=
test_input
.
reshape
((
10000
,
28
,
28
,
1
))
train_input
=
train_input
/
255.0
test_input
=
test_input
/
255.0
######################################################################
model
=
tf
.
keras
.
Sequential
([
tf
.
keras
.
layers
.
Conv2D
(
32
,
(
3
,
3
),
activation
=
tf
.
nn
.
relu
,
input_shape
=
(
28
,
28
,
1
)),
tf
.
keras
.
layers
.
MaxPooling2D
((
2
,
2
)),
tf
.
keras
.
layers
.
Conv2D
(
64
,
(
5
,
5
),
activation
=
tf
.
nn
.
relu
),
tf
.
keras
.
layers
.
MaxPooling2D
((
2
,
2
)),
tf
.
keras
.
layers
.
Flatten
(),
tf
.
keras
.
layers
.
Dense
(
128
,
activation
=
tf
.
nn
.
relu
),
tf
.
keras
.
layers
.
Dense
(
10
,
activation
=
tf
.
nn
.
softmax
)])
model
.
compile
(
optimizer
=
'adam'
,
loss
=
'sparse_categorical_crossentropy'
,
metrics
=
[
'accuracy'
])
model
.
summary
()
model
.
fit
(
train_input
,
train_target
,
batch_size
=
100
,
epochs
=
5
)
test_loss
,
test_acc
=
model
.
evaluate
(
test_input
,
test_target
)
print
(
'Test accuracy:'
,
test_acc
)
Event Timeline
Log In to Comment