# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (Intel, 2018)
#     language: python
#     name: c009-intel_distribution_of_python_3_2018
# ---

import keras
from keras.models import Sequential
from keras.models import Model
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPooling2D
import numpy as np
from keras.models import load_model
from keras.layers.merge import concatenate
from keras.layers import Input, merge

model = Sequential()
model.add(Conv2D(128, kernel_size=(2, 2), activation="relu",input_shape=(4,4,16),padding = 'valid'))
model.add(Conv2D(128, kernel_size=(2, 2), activation="relu",padding = 'valid'))
model.add(Flatten())
model.add(Dense(128,activation="relu"))
model.add(Dropout(0.25))
model.add(Dense(4,activation="softmax"))
model.compile(optimizer='adam',loss='categorical_crossentropy', metrics=['accuracy'])
#model.save('learn_32.h5')  

model1 = Sequential()
model1.add(Conv2D(128, kernel_size=(3, 3), activation="relu",input_shape=(4,4,16),padding = 'same'))
model1.add(Conv2D(128, kernel_size=(2, 2), activation="relu",padding = 'valid'))
model1.add(Conv2D(128, kernel_size=(2, 2), activation="relu",padding = 'valid'))
model1.add(Flatten())
model1.add(Dense(128,activation="relu"))
model1.add(Dropout(0.25))
model1.add(Dense(4,activation="softmax"))
model1.compile(optimizer='adam',loss='categorical_crossentropy', metrics=['accuracy'])
#model1.save('my_highest.h5') 

model2 = Sequential()
model2.add(Conv2D(128, kernel_size=(2, 2), activation="relu",input_shape=(4,4,16),padding = 'valid'))
model2.add(Conv2D(128, kernel_size=(2, 2), activation="relu",input_shape=(4,4,16),padding = 'valid'))
model2.add(Flatten())
model2.add(Dense(256,activation="relu"))
model2.add(Dropout(0.5))
model2.add(Dense(4,activation="softmax"))
model2.compile(optimizer='adam',loss='categorical_crossentropy', metrics=['accuracy'])
#model2.save('my_low.h5')

# +
inputs=Input((4,4,16))
conv = inputs
FLITERS=128
conv41 = Conv2D(filters=FLITERS,kernel_size=(4,1),kernel_initializer= 'he_uniform')(conv)
conv14 = Conv2D(filters=FLITERS,kernel_size=(1,4),kernel_initializer= 'he_uniform')(conv)
conv22 = Conv2D(filters=FLITERS,kernel_size=(2,2),kernel_initializer= 'he_uniform')(conv)
conv33 = Conv2D(filters=FLITERS,kernel_size=(3,3),kernel_initializer= 'he_uniform')(conv)
conv44 = Conv2D(filters=FLITERS,kernel_size=(4,4),kernel_initializer= 'he_uniform')(conv)

hidden=concatenate([Flatten()(conv41),Flatten()(conv14),Flatten()(conv22),Flatten()(conv33),Flatten()(conv44)])

x = keras.layers.BatchNormalization()(hidden)
x = keras.layers.Activation('relu')(hidden)

for width in [512,128]:
    
    x= Dense(width,kernel_initializer = 'he_uniform')(x)
    x=keras.layers.BatchNormalization()(x)
    x =keras.layers.Activation('relu')(x)

outputs = Dense(4,activation = 'softmax')(x)
model3 = Model(inputs, outputs)
model3.summary()
model3.compile(optimizer='adam',loss='categorical_crossentropy', metrics=['accuracy'])
#model3.save('learn_finally.h5')



StarcoderdataJupyterScriptsDedupFiltered