Skip to content

Instantly share code, notes, and snippets.

import pickle
import gzip
import numpy as np
from network2plus import Network
import matplotlib.pyplot as plt
# ── CARICAMENTO DATASET ──────────────────────────────────────
def load_data():
with gzip.open('mnist.pkl.gz', 'rb') as f:
training_data, validation_data, test_data = pickle.load(f, encoding='latin1')
#### Libraries
# Standard library
import json
import random
import sys
# Third-party libraries
import numpy as np
import pickle
import gzip
import numpy as np
from network2 import Network
import matplotlib.pyplot as plt # ← AGGIUNGI QUESTO!
def load_data():
with gzip.open('mnist.pkl.gz', 'rb') as f:
training_data, validation_data, test_data = pickle.load(f, encoding='latin1')
# Preprocess training data
"""network2.py
~~~~~~~~~~~~~~
An improved version of network.py, implementing the stochastic
gradient descent learning algorithm for a feedforward neural network.
Improvements include the addition of the cross-entropy cost function,
regularization, and better initialization of network weights. Note
that I have focused on making the code simple, easily readable, and
easily modifiable. It is not optimized, and omits many desirable
features.
import math as mt
import random as rd
# seed fisso: garantisce risultati identici
# ad ogni esecuzione (riproducibilità)
rd.seed(1)
# ── FUNZIONE SIGMOIDE ──────────────────────────────────────
# trasforma qualsiasi numero in un valore tra 0 e 1
def sigmoide(t):
LAB 1 — Classificatore Husky vs Lupo
import math
# ============================================================
# LAB 1 — Classificatore Husky vs Lupo
# rete con 1 neurone, 2 ingressi, funzione sigmoide
# etichette: 0 = Husky, 1 = Lupo
# ============================================================