Skip to content

Instantly share code, notes, and snippets.

@DiegoAgher
DiegoAgher / model_summary.txt
Created January 3, 2019 20:54
model summary
=================================================================
Total params: 78,519
Trainable params: 78,069
Non-trainable params: 450
@DiegoAgher
DiegoAgher / blurry_sequences.py
Created January 3, 2019 20:44
blurry sequences
seq_length = 9
random_chars = np.random.randint(0, len(x_train)-1, seq_length)
image_seq = []
for j in random_chars:
 if np.random.random(1) >= 0.5:
 image_seq.append(cv2.medianBlur(x_train[j], 5))
 else:
 image_seq.append(x_train[j])
image_seq = np.concatenate(image_seq, axis=1)
@DiegoAgher
DiegoAgher / lstm_prediction.py
Created January 3, 2019 20:39
lstm prediction
y_pred = Dense(num_classes, activation='softmax',
kernel_initializer='he_normal',name='output')(lstm_2)
@DiegoAgher
DiegoAgher / sequence_handling.py
Created January 3, 2019 20:36
sequence handling
lstm_1 = LSTM(32, return_sequences=True, kernel_initializer='he_normal', name='lstm1')(reshape)
lstm_2 = LSTM(32, return_sequences=True, kernel_initializer='he_normal', name='lstm2')(lstm_1)
@DiegoAgher
DiegoAgher / sequence_reshape.py
Created January 3, 2019 20:31
sequenece and reshaping
conv1 = Conv2D(seq_lenght, (3, 3), padding='same', name='conv1', kernel_initializer='he_normal')(inputs)
dims = conv1.get_shape()
reshape = Reshape(target_shape=(seq_lenght, int(dims[1]*dims[2])), name='reshape')(conv1)
@DiegoAgher
DiegoAgher / hybrid_model.py
Last active January 3, 2019 20:36
conv + lstm model
def build_Model(num_classes, seq_lenght, input_shape=(28, 252, 1)):
inputs = Input(name='x', shape=input_shape, dtype='float32')
conv1 = Conv2D(seq_lenght, (3, 3), padding='same', name='conv1', kernel_initializer='he_normal')(inputs)
conv1 = Activation('relu')(conv1)
conv1 = MaxPooling2D(pool_size=(2, 2), name='max1')(conv1)
dims = conv1.get_shape()
reshape = Reshape(target_shape=(seq_lenght, int(dims[1]*dims[2])), name='reshape')(conv1)
@DiegoAgher
DiegoAgher / sequence_viz.py
Last active January 3, 2019 23:23
sequence visualization
plt.imshow(image_seq)
@DiegoAgher
DiegoAgher / mnist_seq.py
Created January 3, 2019 19:52
mnist sequence
seq_length = 9
random_chars = np.random.randint(0, len(x_train)-1, seq_length)
image_seq = np.concatenate([x_train[j] for j in random_chars], axis=1)
seq_label = np.array([y_train[j] for j in random_chars])
@DiegoAgher
DiegoAgher / mnist_keras.py
Created January 3, 2019 19:50
mnist_keras
from keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
### Keybase proof
I hereby claim:
* I am diegoagher on github.
* I am agher (https://keybase.io/agher) on keybase.
* I have a public key ASBfCDf3tTF7YMTy4Ut1T13OfCHuZLcE-Mz0MTKzrZs7Rwo
To claim this, I am signing this object: