Skip to content

Instantly share code, notes, and snippets.

View adriaciurana's full-sized avatar

Adrià Ciurana Lanau adriaciurana

  • Canva
  • Sydney, NSW, Australia
  • 19:28 (UTC +10:00)
View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from mpl_toolkits.mplot3d import Axes3D
# numero iteraciones
ITERS = 10000
# learning rate
LR = 0.0000000001
@adriaciurana
adriaciurana / Test SVD
Created May 30, 2018 15:03
Post 2 BigNeuralNetwork
A = roty(-30); B = 2; C = rotx(45);
[A2, B2, C2] = svd(A*B*C);
if(sum(sum(abs(A2)-abs(A))) < 1e-10 && ...
sum(sum(abs(B2)-abs(B))) < 1e-10 && ...
sum(sum(abs(C2)-abs(C))) < 1e-10)
disp('La descomposicion da como resultado A, B, C iguales en magnitud');
end
@adriaciurana
adriaciurana / RBM.ipynb
Created November 1, 2018 17:32
RBM para bigneuralvision.com
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adriaciurana
adriaciurana / prediction.py
Created January 22, 2019 13:52
Medium Articulo: Parte 5
import argparse, keras, os
from keras.models import model_from_json
parser = argparse.ArgumentParser()
parser.add_argument("image", help="Image or folder of images to predict",
type=str)
args = parser.parse_args()
# Cargamos el modelo
json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
@adriaciurana
adriaciurana / parser.py
Created January 22, 2019 13:58
Medium Articulo: Parte 5a
import argparse, keras, os, cv2
from keras.models import model_from_json
parser = argparse.ArgumentParser()
parser.add_argument("image", help="Image or folder of images to predict",
type=str)
args = parser.parse_args()
@adriaciurana
adriaciurana / load_mode.py
Created January 22, 2019 13:59
Articulo Medium 5b
# Cargamos el modelo
json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
model = model_from_json(loaded_model_json)
model.load_weights("model.h5")
@adriaciurana
adriaciurana / load_images.py
Created January 22, 2019 14:01
Articulo Medium: Parte 5c
# Cargamos la imagen/imagenes
if os.path.isdir(args.image):
path_images = []
for ext in ['jpg', 'jpeg', 'tiff', 'png', 'gif']:
path_images += glob.glob(os.path.join(args.image, "*." + ext))
else:
path_images = [args.image]
images = []
for path_im in path_images:
@adriaciurana
adriaciurana / monitor.txt
Created January 22, 2019 14:07
Articulo Medium: Parte5 monitor
Epoch 50/50
...
2000/2000 [==============================] - 158s 79ms/step - loss: 0.1001 - binary_accuracy: 0.9613 - val_loss: 0.6304 - val_binary_accuracy: 0.8426
@adriaciurana
adriaciurana / model.py
Last active January 23, 2019 10:06
Medium Articulo: Parte 2
# Cargamos la clase para generar modelos sequenciales
from keras.models import Sequential
# Cargamos las siguientes capas
from keras.layers import Conv2D, MaxPooling2D, Dense, Flatten
model = Sequential()
# Bloque 1:
# - Conv1a: neuronas=128, ventana=(3,3), activacion=ReLU.
# - Conv1b: neuronas=256, ventana=(3,3), activacion=ReLU.
# - Max-pooling: ventana=(3,3), stride=2.
@adriaciurana
adriaciurana / compile.py
Last active January 23, 2019 10:06
Medium Articulo 3
# Usamos el optimizador Adam
# Usamos la loss function binary_crossentropy. Esta es util cuando la red devuelve una probabilidad, es este caso ser perro o ser gato.
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['binary_accuracy'])
model.summary()