mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
CNN Intro
This commit is contained in:
parent
551102b9e7
commit
49b8552172
4 changed files with 108 additions and 6 deletions
19
presentations/CNN-Intro/cnn.py
Normal file
19
presentations/CNN-Intro/cnn.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import data
|
||||
|
||||
from keras.layers import Dense, Flatten, Conv2D, MaxPooling2D
|
||||
from keras.models import Sequential, load_model
|
||||
|
||||
model = Sequential()
|
||||
model.add(Conv2D(16, (3, 3)))
|
||||
model.add(MaxPooling2D(pool_size=(2, 2)))
|
||||
model.add(Conv2D(16, (3, 3)))
|
||||
model.add(Flatten())
|
||||
model.add(Dense(128, activation='relu'))
|
||||
model.add(Dense(data.n_classes, activation='softmax'))
|
||||
|
||||
model.compile(loss='categorical_crossentropy', optimizer='adam')
|
||||
model.fit(data.x_train, data.y_train)
|
||||
|
||||
model.save('model.h5')
|
||||
model = load_model('model.h5')
|
||||
y_predicted = model.predict(data.x_test)
|
Loading…
Add table
Add a link
Reference in a new issue