-
Notifications
You must be signed in to change notification settings - Fork 0
/
count.py
34 lines (30 loc) · 1002 Bytes
/
count.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import tensorflow as tf
from tensorflow import keras
import numpy as np
import os
def main():
input_data = np.array(([0,0,0], [0,0,1], [0,1,0], [0,1,1], [1,0,0], [1,0,1], [1,1,0], [1,1,1]), dtype=np.float32)
label_data = np.array([0, 1, 1, 2, 1, 2, 2, 3], dtype=np.int32)
train_data, train_label = input_data, label_data
validation_data, validation_label = input_data, label_data
model = keras.Sequential(
[
keras.layers.Dense(6, activation='relu'),
keras.layers.Dense(6, activation='relu'),
keras.layers.Dense(4, activation='softmax'),
]
)
model.compile(
optimizer='adam', loss='sparse_categorical_crossentropy',
metrics=['accuracy']
)
model.fit(
x=train_data,
y=train_label,
epochs=1000,
batch_size=8,
validation_data=(validation_data, validation_label),
),
model.save(os.path.join('result', 'outmodel'))
if __name__ == "__main__":
main()