Last active
November 21, 2022 05:49
-
-
Save omaraflak/b2eab7329f4169fe21a532162126f6c1 to your computer and use it in GitHub Desktop.
Part of : https://medium.com/datadriveninvestor/math-neural-network-from-scratch-in-python-d6da9f29ce65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MNIST is a Classification problem; However, MSE is used for Regression problems. I believe you got that wrong.