import numpy as np
from utils import _initialize, optimizer, plot_prediction

np.random.seed(428)

# ========================= EDIT HERE =========================
# 1. Choose DATA : Digit, Iris
# 2. Adjust Hyperparameters
# 3. Choose Optimizer : SGD / Momentum / RMSProp

# DATA
DATA_NAME = None

# HYPERPARAMETERS
batch_size = None
num_epochs = None
learning_rate = None
epsilon = None
gamma = None
show_plot = True    # show prediction sample images for DIGIT dataset

# OPTIMIZER
OPTIMIZER = None
# =============================================================
assert DATA_NAME in ['Digit', 'Iris']
assert OPTIMIZER in ['SGD', 'Momentum', 'RMSProp']

# Load dataset, model and evaluation metric
train_data, test_data, softmax_classifier, accuracy = _initialize(DATA_NAME)
train_x, train_y = train_data
if DATA_NAME == 'Digit':
    train_x, mean_img = train_x

num_data, num_features = train_x.shape
num_label = int(train_y.max()) + 1
print('# of Training data : %d \n' % num_data)

# Make model & optimizer
model = softmax_classifier(num_features, num_label)
optim = optimizer(OPTIMIZER, gamma=gamma, epsilon=epsilon)

# TRAIN
loss = model.train(train_x, train_y, num_epochs, batch_size, learning_rate, optim)
print('Training Loss at last epoch: %.4f' % loss)

# EVALUATION
test_x, test_y = test_data
pred = model.eval(test_x)

acc = accuracy(pred, test_y)
print(OPTIMIZER, ' Accuracy on Test Data : %.2f' % acc)

# Visualize predictions for Digit dataset
if show_plot and DATA_NAME == 'Digit':
    test_x = test_x[:, 1:] + mean_img
    plot_prediction(test_x, pred, test_y)
import numpy as np
from utils import _initialize, optimizer, plot_prediction

np.random.seed(428)

# ========================= EDIT HERE =========================
# 1. Choose DATA : Digit, Iris
# 2. Adjust Hyperparameters
# 3. Choose Optimizer : SGD / Momentum / RMSProp

# DATA
DATA_NAME = None

# HYPERPARAMETERS
batch_size = None
num_epochs = None
learning_rate = None
epsilon = None
gamma = None
show_plot = True    # show prediction sample images for DIGIT dataset

# OPTIMIZER
OPTIMIZER = None
# =============================================================
assert DATA_NAME in ['Digit', 'Iris']
assert OPTIMIZER in ['SGD', 'Momentum', 'RMSProp']

# Load dataset, model and evaluation metric
train_data, test_data, softmax_classifier, accuracy = _initialize(DATA_NAME)
train_x, train_y = train_data
if DATA_NAME == 'Digit':
    train_x, mean_img = train_x

num_data, num_features = train_x.shape
num_label = int(train_y.max()) + 1
print('# of Training data : %d \n' % num_data)

# Make model & optimizer
model = softmax_classifier(num_features, num_label)
optim = optimizer(OPTIMIZER, gamma=gamma, epsilon=epsilon)

# TRAIN
loss = model.train(train_x, train_y, num_epochs, batch_size, learning_rate, optim)
print('Training Loss at last epoch: %.4f' % loss)

# EVALUATION
test_x, test_y = test_data
pred = model.eval(test_x)

acc = accuracy(pred, test_y)
print(OPTIMIZER, ' Accuracy on Test Data : %.2f' % acc)

# Visualize predictions for Digit dataset
if show_plot and DATA_NAME == 'Digit':
    test_x = test_x[:, 1:] + mean_img
    plot_prediction(test_x, pred, test_y)
# ========================= EDIT HERE ========================= # 1. Choose DATA : Digit, Iris # 2. Adjust Hyperparameters # 3. Choose Optimizer : SGD / Momentum / RMSProp # DATA # HYPERPARAMETERS # show prediction sample images for DIGIT dataset # OPTIMIZER # ============================================================= # Load dataset, model and evaluation metric # Make model & optimizer # TRAIN # EVALUATION # Visualize predictions for Digit dataset