You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
821 B
Python
35 lines
821 B
Python
5 years ago
|
import tensorflow as tf
|
||
|
from tensorflow import keras
|
||
|
|
||
|
import pandas as pd
|
||
|
import numpy as np
|
||
|
|
||
|
train_df = pd.read_csv('./data/train.csv')
|
||
|
np.random.shuffle(train_df.values)
|
||
|
|
||
|
print(train_df.head())
|
||
|
|
||
|
model = keras.Sequential([
|
||
|
keras.layers.Dense(32, input_shape=(2,), activation='relu'),
|
||
|
keras.layers.Dense(32, activation='relu'),
|
||
|
keras.layers.Dense(2, activation='sigmoid')])
|
||
|
|
||
|
model.compile(optimizer='adam',
|
||
|
loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
|
||
|
metrics=['accuracy'])
|
||
|
|
||
|
x = np.column_stack((train_df.x.values, train_df.y.values))
|
||
|
|
||
|
model.fit(x, train_df.color.values, batch_size=4, epochs=10)
|
||
|
|
||
|
test_df = pd.read_csv('./data/test.csv')
|
||
|
test_x = np.column_stack((test_df.x.values, test_df.y.values))
|
||
|
|
||
|
print("EVALUATION")
|
||
|
model.evaluate(test_x, test_df.color.values)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|