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.
38 lines
925 B
Python
38 lines
925 B
Python
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(256, input_shape=(2,), activation='relu'),
|
|
keras.layers.Dropout(0.4),
|
|
keras.layers.Dense(128, activation='relu'),
|
|
keras.layers.Dropout(0.4),
|
|
keras.layers.Dense(128, 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=32, epochs=20)
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|