Skip to content

Instantly share code, notes, and snippets.

@omaraflak
Last active November 21, 2022 05:49
Show Gist options
  • Save omaraflak/b2eab7329f4169fe21a532162126f6c1 to your computer and use it in GitHub Desktop.
Save omaraflak/b2eab7329f4169fe21a532162126f6c1 to your computer and use it in GitHub Desktop.
import numpy as np
from network import Network
from fc_layer import FCLayer
from activation_layer import ActivationLayer
from activations import tanh, tanh_prime
from losses import mse, mse_prime
# training data
x_train = np.array([[[0,0]], [[0,1]], [[1,0]], [[1,1]]])
y_train = np.array([[[0]], [[1]], [[1]], [[0]]])
# network
net = Network()
net.add(FCLayer(2, 3))
net.add(ActivationLayer(tanh, tanh_prime))
net.add(FCLayer(3, 1))
net.add(ActivationLayer(tanh, tanh_prime))
# train
net.use(mse, mse_prime)
net.fit(x_train, y_train, epochs=1000, learning_rate=0.1)
# test
out = net.predict(x_train)
print(out)
@keivanipchihagh
Copy link

keivanipchihagh commented Nov 21, 2022

MNIST is a Classification problem; However, MSE is used for Regression problems. I believe you got that wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment