<jupyter_start><jupyter_text>TFBS Classification - ResNET Papers : https://arxiv.org/abs/1512.03385 (architecture), https://arxiv.org/abs/1605.01133 (data)<jupyter_code>import os
import numpy as np
from keras.models import Sequential,Model
from keras.layers import Dropout ,Activation,AveragePooling2D, normalization,Convolution2D
from keras.layers import Dense, Flatten, Reshape, Input
from keras.layers.merge import add
from keras import optimizers
from keras.utils import np_utils
from matplotlib import pyplot as plt
%matplotlib inline
X = np.load('X_TFBS.npy')
y = np.load('Y_TFBS.npy')
Y = np_utils.to_categorical(y)
print X.shape, Y.shape
inp = Input(shape=(101,1,4))

x1 = Convolution2D( 128,(5,1))(inp)

r1_a1 = Activation('relu')(x1)
r1_w1 = Convolution2D(128,( 5,1),padding='same')(r1_a1)
r1_a2 = Activation('relu')(r1_w1)
r1_d1 = Dropout(0.2)(r1_a2)
r1_w2 = Convolution2D(128,( 5,1),padding='same')(r1_d1)
x2 = add([x1, r1_w2])

r2_a1 = Activation('relu')(x2)
r2_w1 = Convolution2D(128,( 5,1),padding='same')(r2_a1)
r2_a2 = Activation('relu')(r2_w1)
r2_d1 = Dropout(0.2)(r2_a2)
r2_w2 = Convolution2D(128,( 5,1),padding='same')(r2_d1)
x3 = add([x2, r2_w2])

acti = Activation('relu')(x3)
av_pool = AveragePooling2D((97,1))((acti))
f1 = Flatten()(av_pool)
fc1 = Dense(32)(f1)
a1 = Activation('relu')(fc1)
fc2 = Dense(2)(a1)
a2 = Activation('softmax')(fc2)

model = Model(outputs=a2, inputs=inp)
model.summary()
adam = optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08, decay=0.0003)        
model.compile(loss='categorical_crossentropy', optimizer=adam, metrics=['accuracy'])
X = X.reshape(X.shape[0], 101, 1, 4)
hist = model.fit(X, Y,epochs = 20,shuffle=True,batch_size=256,validation_split=0.20)
plt.plot(hist.history['acc'],'g')
plt.plot(hist.history['val_acc'],'b')
plt.plot(hist.history['loss'],'r')
plt.plot(hist.history['val_loss'],'black')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18024172359432475, 'fraction_numerical': 0.08302679978980557, 'mean_word_length': 7.424778761061947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '472554', 'license': 'MIT', 'n_tokens_mistral': 898, 'n_tokens_neox': 829, 'n_words': 134, 'path': 'TFBS-ResNets.ipynb', 'repo_name': 'vasu-dev/SC-Project', 'size': '1903'}