Skip to content

Commit 2f13565

Browse files
committed
Repository created
1 parent 63e2360 commit 2f13565

File tree

5 files changed

+427
-0
lines changed

5 files changed

+427
-0
lines changed

Activity01/mnist.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
# In[5]:
5+
6+
7+
import tensorflow as tf
8+
from tensorflow import keras
9+
from tensorflow.keras.models import Sequential
10+
from tensorflow.keras.layers import Convolution2D, Flatten, Dense, Dropout
11+
import datetime
12+
13+
from keras.optimizers import adam
14+
15+
16+
# In[17]:
17+
18+
19+
mnist = tf.keras.datasets.mnist
20+
21+
(X_train, y_train), (X_test, y_test) = mnist.load_data()
22+
X_train, X_test = X_train / 255.0, X_test / 255.0
23+
24+
25+
# In[20]:
26+
27+
log_dir="logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
28+
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)
29+
30+
31+
X_train = X_train.reshape(X_train.shape[0],X_train.shape[1], X_train.shape[2],1)
32+
X_test = X_test.reshape(X_test.shape[0],X_test.shape[1], X_test.shape[2],1)
33+
34+
35+
# In[21]:
36+
37+
38+
model = Sequential()
39+
model.add(Convolution2D(filters = 10, kernel_size = 3, input_shape=(28,28,1)))
40+
model.add(Flatten())
41+
model.add(Dense(128, activation = 'relu'))
42+
model.add(Dropout(0.2))
43+
model.add(Dense(10, activation = 'softmax'))
44+
45+
46+
47+
48+
# In[22]:
49+
50+
learning_rate=0.001
51+
52+
53+
model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate = learning_rate),
54+
loss='sparse_categorical_crossentropy',
55+
metrics=['accuracy'])
56+
57+
58+
# In[23]:
59+
60+
61+
model.fit(X_train, y_train, epochs=5, validation_data=(X_test, y_test),callbacks=[tensorboard_callback])
62+
63+
64+
# In[ ]:
65+
66+
67+
68+

Activity01/requirements.txt

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
absl-py==0.8.1
2+
astor==0.8.0
3+
attrs==19.3.0
4+
backcall==0.1.0
5+
beautifulsoup4==4.8.1
6+
bleach==3.1.0
7+
cachetools==3.1.1
8+
certifi==2019.9.11
9+
chardet==3.0.4
10+
Click==7.0
11+
cycler==0.10.0
12+
decorator==4.4.1
13+
defusedxml==0.6.0
14+
entrypoints==0.3
15+
Flask==1.1.1
16+
Flask-API==2.0
17+
Flask-Caching==1.8.0
18+
Flask-Cors==3.0.8
19+
Flask-Testing==0.7.1
20+
gast==0.2.2
21+
google-auth==1.7.0
22+
google-auth-oauthlib==0.4.1
23+
google-pasta==0.1.8
24+
graphviz==0.13.2
25+
grpcio==1.24.3
26+
h5py==2.10.0
27+
html5lib==1.0.1
28+
idna==2.8
29+
importlib-metadata==1.3.0
30+
ipykernel==5.1.3
31+
ipython==7.10.2
32+
ipython-genutils==0.2.0
33+
ipywidgets==7.5.1
34+
itsdangerous==1.1.0
35+
jedi==0.15.2
36+
Jinja2==2.10.3
37+
jsonschema==3.2.0
38+
jupyter==1.0.0
39+
jupyter-client==5.3.4
40+
jupyter-console==6.0.0
41+
jupyter-core==4.6.1
42+
Keras==2.2.4
43+
Keras-Applications==1.0.8
44+
Keras-Preprocessing==1.1.0
45+
kiwisolver==1.1.0
46+
Markdown==3.1.1
47+
MarkupSafe==1.1.1
48+
matplotlib==3.1.2
49+
mistune==0.8.4
50+
more-itertools==8.0.2
51+
nbconvert==5.6.1
52+
nbformat==4.4.0
53+
notebook==6.0.2
54+
numpy==1.17.3
55+
oauthlib==3.1.0
56+
opt-einsum==3.1.0
57+
pandas==0.25.3
58+
pandocfilters==1.4.2
59+
parso==0.5.2
60+
pexpect==4.7.0
61+
pickleshare==0.7.5
62+
prometheus-client==0.7.1
63+
prompt-toolkit==2.0.10
64+
protobuf==3.10.0
65+
ptyprocess==0.6.0
66+
pyasn1==0.4.7
67+
pyasn1-modules==0.2.7
68+
Pygments==2.5.2
69+
pyparsing==2.4.5
70+
pyrsistent==0.15.6
71+
python-dateutil==2.8.1
72+
pytz==2019.3
73+
PyYAML==5.2
74+
pyzmq==18.1.1
75+
qtconsole==4.6.0
76+
requests==2.22.0
77+
requests-oauthlib==1.2.0
78+
rsa==4.0
79+
scipy==1.4.1
80+
seaborn==0.9.0
81+
Send2Trash==1.5.0
82+
six==1.13.0
83+
soupsieve==1.9.5
84+
tensorboard==2.0.1
85+
tensorflow==2.0.0
86+
tensorflow-estimator==2.0.1
87+
termcolor==1.1.0
88+
terminado==0.8.3
89+
testpath==0.4.4
90+
tornado==6.0.3
91+
tqdm==4.41.0
92+
traitlets==4.3.3
93+
urllib3==1.25.6
94+
wcwidth==0.1.7
95+
webencodings==0.5.1
96+
Werkzeug==0.16.0
97+
widgetsnbextension==3.5.1
98+
wrapt==1.11.2
99+
zipp==0.6.0

Exercise01/requirements.txt

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
absl-py==0.8.1
2+
astor==0.8.0
3+
attrs==19.3.0
4+
backcall==0.1.0
5+
beautifulsoup4==4.8.1
6+
bleach==3.1.0
7+
cachetools==3.1.1
8+
certifi==2019.9.11
9+
chardet==3.0.4
10+
Click==7.0
11+
cycler==0.10.0
12+
decorator==4.4.1
13+
defusedxml==0.6.0
14+
entrypoints==0.3
15+
Flask==1.1.1
16+
Flask-API==2.0
17+
Flask-Caching==1.8.0
18+
Flask-Cors==3.0.8
19+
Flask-Testing==0.7.1
20+
gast==0.2.2
21+
google-auth==1.7.0
22+
google-auth-oauthlib==0.4.1
23+
google-pasta==0.1.8
24+
graphviz==0.13.2
25+
grpcio==1.24.3
26+
h5py==2.10.0
27+
html5lib==1.0.1
28+
idna==2.8
29+
importlib-metadata==1.3.0
30+
ipykernel==5.1.3
31+
ipython==7.10.2
32+
ipython-genutils==0.2.0
33+
ipywidgets==7.5.1
34+
itsdangerous==1.1.0
35+
jedi==0.15.2
36+
Jinja2==2.10.3
37+
jsonschema==3.2.0
38+
jupyter==1.0.0
39+
jupyter-client==5.3.4
40+
jupyter-console==6.0.0
41+
jupyter-core==4.6.1
42+
Keras==2.2.4
43+
Keras-Applications==1.0.8
44+
Keras-Preprocessing==1.1.0
45+
kiwisolver==1.1.0
46+
Markdown==3.1.1
47+
MarkupSafe==1.1.1
48+
matplotlib==3.1.2
49+
mistune==0.8.4
50+
more-itertools==8.0.2
51+
nbconvert==5.6.1
52+
nbformat==4.4.0
53+
notebook==6.0.2
54+
numpy==1.17.3
55+
oauthlib==3.1.0
56+
opt-einsum==3.1.0
57+
pandas==0.25.3
58+
pandocfilters==1.4.2
59+
parso==0.5.2
60+
pexpect==4.7.0
61+
pickleshare==0.7.5
62+
prometheus-client==0.7.1
63+
prompt-toolkit==2.0.10
64+
protobuf==3.10.0
65+
ptyprocess==0.6.0
66+
pyasn1==0.4.7
67+
pyasn1-modules==0.2.7
68+
Pygments==2.5.2
69+
pyparsing==2.4.5
70+
pyrsistent==0.15.6
71+
python-dateutil==2.8.1
72+
pytz==2019.3
73+
PyYAML==5.2
74+
pyzmq==18.1.1
75+
qtconsole==4.6.0
76+
requests==2.22.0
77+
requests-oauthlib==1.2.0
78+
rsa==4.0
79+
scipy==1.4.1
80+
seaborn==0.9.0
81+
Send2Trash==1.5.0
82+
setuptools==41.0.0
83+
six==1.13.0
84+
soupsieve==1.9.5
85+
tensorboard==2.0.1
86+
tensorflow==2.0.0
87+
tensorflow-estimator==2.0.1
88+
termcolor==1.1.0
89+
terminado==0.8.3
90+
testpath==0.4.4
91+
tornado==6.0.3
92+
tqdm==4.41.0
93+
traitlets==4.3.3
94+
urllib3==1.25.6
95+
wcwidth==0.1.7
96+
webencodings==0.5.1
97+
Werkzeug==0.16.0
98+
widgetsnbextension==3.5.1
99+
wrapt==1.11.2
100+
zipp==0.6.0

Exercise02/mnist.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
# In[5]:
5+
6+
7+
import tensorflow as tf
8+
from tensorflow import keras
9+
from tensorflow.keras.models import Sequential
10+
from tensorflow.keras.layers import Convolution2D, Flatten, Dense, Dropout
11+
import datetime
12+
13+
# In[17]:
14+
15+
16+
mnist = tf.keras.datasets.mnist
17+
18+
(X_train, y_train), (X_test, y_test) = mnist.load_data()
19+
X_train, X_test = X_train / 255.0, X_test / 255.0
20+
21+
22+
# In[20]:
23+
24+
log_dir="logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
25+
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)
26+
27+
28+
X_train = X_train.reshape(X_train.shape[0],X_train.shape[1], X_train.shape[2],1)
29+
X_test = X_test.reshape(X_test.shape[0],X_test.shape[1], X_test.shape[2],1)
30+
31+
32+
# In[21]:
33+
34+
35+
model = Sequential()
36+
model.add(Convolution2D(filters = 10, kernel_size = 3, input_shape=(28,28,1)))
37+
model.add(Flatten())
38+
model.add(Dense(128, activation = 'relu'))
39+
model.add(Dropout(0.2))
40+
model.add(Dense(10, activation = 'softmax'))
41+
42+
43+
# In[22]:
44+
45+
46+
model.compile(optimizer='adam',
47+
loss='sparse_categorical_crossentropy',
48+
metrics=['accuracy'])
49+
50+
51+
# In[23]:
52+
53+
54+
model.fit(X_train, y_train, epochs=5, validation_data=(X_test, y_test),callbacks=[tensorboard_callback])
55+
56+
57+
# In[ ]:
58+
59+
60+
61+

0 commit comments

Comments
 (0)