Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Giuseppe Bonaccorso giuseppebonaccorso

🎯
Focusing
View GitHub Profile
@giuseppebonaccorso
giuseppebonaccorso / hetero-encoder.py
Created Dec 31, 2017
Stories with Convolutional Hetero-Encoders
View hetero-encoder.py
import matplotlib.pyplot as plt
import multiprocessing
import numpy as np
import tensorflow as tf
from keras.datasets import cifar10
# Set random seed (for reproducibility)
np.random.seed(1000)
tf.set_random_seed(1000)
@giuseppebonaccorso
giuseppebonaccorso / som-olivetti-cupy.py
Last active Oct 22, 2017
Example of Self-Organizing Map (Kohonen Network) based on the Olivetti faces dataset (Cupy-based)
View som-olivetti-cupy.py
import cupy as cp
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import fetch_olivetti_faces
# Set random seed for reproducibility
np.random.seed(1000)
cp.random.seed(1000)
View passive_aggressive_regression.py
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import make_regression
# Set random seed (for reproducibility)
np.random.seed(1000)
nb_samples = 500
nb_features = 4
View passive_aggressive_classification.py
import numpy as np
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
# Set random seed (for reproducibility)
np.random.seed(1000)
nb_samples = 5000
@giuseppebonaccorso
giuseppebonaccorso / rubner-tavan-pca-network.py
Last active Dec 4, 2017
PCA with Rubner-Tavan Networks
View rubner-tavan-pca-network.py
from sklearn.datasets import load_digits
import numpy as np
# Set random seed for reproducibility
np.random.seed(1000)
# Load MNIST dataset
X, Y = load_digits(return_X_y=True)
X /= 255.0
View brain-state-in-a-box.py
import matplotlib.pyplot as plt
import numpy as np
# Set random seed for reproducibility
np.random.seed(1000)
nb_patterns = 4
pattern_width = 4
pattern_height = 4
max_iterations = 100
View hopfield.py
import matplotlib.pyplot as plt
import numpy as np
# Set random seed for reproducibility
np.random.seed(1000)
nb_patterns = 4
pattern_width = 4
pattern_height = 4
max_iterations = 10
View quickprop.py
from sklearn.datasets import make_classification
import numpy as np
# Set random seed (for reproducibility)
np.random.seed(1000)
def sigmoid(arg):
return 1.0 / (1.0 + np.exp(-arg))
@giuseppebonaccorso
giuseppebonaccorso / model_free_collaborative_filtering.py
Last active Apr 17, 2018
A model-free collaborative recommendation system in 20 lines of Python
View model_free_collaborative_filtering.py
from scipy.sparse import dok_matrix
from sklearn.metrics.pairwise import pairwise_distances
import numpy as np
# Set random seed (for reproducibility)
np.random.seed(1000)
# Create a dummy user-item dataset
nb_users = 1000
@giuseppebonaccorso
giuseppebonaccorso / fim.py
Created Sep 2, 2017
Fisher Information Matrix
View fim.py
import numpy as np
import tensorflow as tf
from sklearn.datasets import make_blobs
# Set random seed (for reproducibility)
np.random.seed(1000)
# Create dataset
nb_samples=2000
You can’t perform that action at this time.