Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kiryuu Sakuya
TensorFlow-Homework
Commits
5a6075a9
Unverified
Commit
5a6075a9
authored
Mar 10, 2020
by
Kiryuu Sakuya
🎵
Browse files
Finish 06
parent
9f8762fb
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
06. cifar-10-convolutional-network-implementation/logs/2020-03-10-12-52-27/train/events.out.tfevents.1583815947.MISAKANET-CUDA.5460.720.v2
0 → 100644
View file @
5a6075a9
File added
06. cifar-10-convolutional-network-implementation/logs/2020-03-10-12-52-27/train/events.out.tfevents.1583815949.MISAKANET-CUDA.profile-empty
0 → 100644
View file @
5a6075a9
File added
06. cifar-10-convolutional-network-implementation/logs/2020-03-10-12-52-27/train/plugins/profile/2020-03-10_12-52-29/local.trace
0 → 100644
View file @
5a6075a9
File added
06. cifar-10-convolutional-network-implementation/logs/2020-03-10-12-52-27/validation/events.out.tfevents.1583815959.MISAKANET-CUDA.5460.13620.v2
0 → 100644
View file @
5a6075a9
File added
06. cifar-10-convolutional-network-implementation/logs/2020-03-10-13-03-58/train/events.out.tfevents.1583816638.MISAKANET-CUDA.6556.720.v2
0 → 100644
View file @
5a6075a9
File added
06. cifar-10-convolutional-network-implementation/logs/2020-03-10-13-03-58/train/events.out.tfevents.1583816640.MISAKANET-CUDA.profile-empty
0 → 100644
View file @
5a6075a9
File added
06. cifar-10-convolutional-network-implementation/logs/2020-03-10-13-03-58/train/plugins/profile/2020-03-10_13-04-00/local.trace
0 → 100644
View file @
5a6075a9
File added
06. cifar-10-convolutional-network-implementation/logs/2020-03-10-13-03-58/validation/events.out.tfevents.1583816650.MISAKANET-CUDA.v2
0 → 100644
View file @
5a6075a9
File added
06. cifar-10-convolutional-network-implementation/main.ipynb
0 → 100644
View file @
5a6075a9
This diff is collapsed.
Click to expand it.
06. cifar-10-convolutional-network-implementation/main.py
0 → 100644
View file @
5a6075a9
# -*- coding: utf-8 -*-
import
tensorflow
as
tf
import
tensorflow_datasets
as
tfds
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
datetime
as
dt
datasets
=
tfds
.
load
(
"cifar10"
)
train_dataset
,
test_dataset
=
datasets
[
"train"
],
datasets
[
"test"
]
assert
isinstance
(
train_dataset
,
tf
.
data
.
Dataset
)
cifar10_builder
=
tfds
.
builder
(
"cifar10"
)
# See the information on the dataset
# info = cifar10_builder.info
# print(info)
for
batch
in
train_dataset
.
batch
(
50000
):
x_train
=
batch
[
'image'
]
y_train
=
batch
[
'label'
].
numpy
().
astype
(
'uint8'
)
for
batch
in
test_dataset
.
batch
(
10000
):
x_test
=
batch
[
'image'
]
y_test
=
batch
[
'label'
].
numpy
().
astype
(
'uint8'
)
# Normalize pixel values to be between 0 and 1
x_test
=
x_test
/
255
x_train
=
x_train
/
255
model
=
tf
.
keras
.
models
.
Sequential
([
tf
.
keras
.
layers
.
Conv2D
(
32
,
(
3
,
3
),
activation
=
'relu'
,
padding
=
'same'
,
input_shape
=
(
32
,
32
,
3
)),
tf
.
keras
.
layers
.
Conv2D
(
32
,
(
3
,
3
),
activation
=
'relu'
),
tf
.
keras
.
layers
.
MaxPooling2D
((
2
,
2
)),
tf
.
keras
.
layers
.
Conv2D
(
64
,
(
3
,
3
),
padding
=
'same'
,
activation
=
'relu'
),
tf
.
keras
.
layers
.
Conv2D
(
64
,
(
3
,
3
),
activation
=
'relu'
),
tf
.
keras
.
layers
.
MaxPooling2D
((
2
,
2
)),
tf
.
keras
.
layers
.
Conv2D
(
128
,
(
3
,
3
),
padding
=
'same'
,
activation
=
'relu'
),
tf
.
keras
.
layers
.
Conv2D
(
128
,
(
3
,
3
),
activation
=
'relu'
),
tf
.
keras
.
layers
.
Flatten
(),
tf
.
keras
.
layers
.
Dense
(
512
,
activation
=
'relu'
),
tf
.
keras
.
layers
.
Dense
(
10
,
activation
=
'softmax'
)
])
model
.
compile
(
optimizer
=
'adam'
,
loss
=
'sparse_categorical_crossentropy'
,
metrics
=
[
'accuracy'
])
model
.
summary
()
callbacks
=
[
# Write TensorBoard logs to `./logs` directory
tf
.
keras
.
callbacks
.
TensorBoard
(
log_dir
=
'logs/{}'
.
format
(
dt
.
datetime
.
now
().
strftime
(
"%Y-%m-%d-%H-%M-%S"
)))
]
history
=
model
.
fit
(
x_train
,
y_train
,
epochs
=
50
,
validation_data
=
(
x_test
,
y_test
),
callbacks
=
callbacks
)
# plt.plot(history.history['accuracy'], label='accuracy')
# plt.plot(history.history['val_accuracy'], label = 'val_accuracy')
# plt.xlabel('Epoch')
# plt.ylabel('Accuracy')
# plt.ylim([0.5, 1])
# plt.legend(loc='lower right')
test_loss
,
test_acc
=
model
.
evaluate
(
x_test
,
y_test
,
verbose
=
0
)
print
(
test_acc
)
\ No newline at end of file
06. cifar-10-convolutional-network-implementation/output.txt
0 → 100644
View file @
5a6075a9
This diff is collapsed.
Click to expand it.
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