-
Notifications
You must be signed in to change notification settings - Fork 0
/
p-Snet_model.py
84 lines (68 loc) · 2.2 KB
/
p-Snet_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 1 16:01:37 2020
@author: arshdeep
"""
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import h5py
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Conv1D, MaxPooling1D, ZeroPadding1D,AveragePooling1D
from keras import backend as K
from keras.layers.normalization import BatchNormalization
#import theano
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from keras import backend as K
K.set_image_dim_ordering('th')
import tensorflow as tf
from keras.models import Model
from keras.models import load_model
#%%
weight_path='~/p-Snet_weights.hdf5'
#%%
model =Sequential()
model.add(Conv1D(16,64,strides=2,input_shape=(None,1))) #layer1
model.add(ZeroPadding1D(padding=16))
model.add(BatchNormalization()) #layer2
convout1= Activation('relu')
model.add(convout1) #layer3
model.add(MaxPooling1D(pool_size=8, padding='valid')) #layer4
#
#
model.add(Conv1D(32,32,strides=2)) #layer5
model.add(ZeroPadding1D(padding=8))
model.add(BatchNormalization()) #layer6
convout2= Activation('relu')
model.add(convout2) #layer7
model.add(MaxPooling1D(pool_size=8, padding='valid')) #layer8
model.add(Conv1D(41,16,strides=2)) #layer9
model.add(ZeroPadding1D(padding=4))
model.add(BatchNormalization()) #layer10
convout3= Activation('relu')
model.add(convout3) #layer11
model.add(Conv1D(56,8,strides=2)) #layer12
model.add(ZeroPadding1D(padding=2))
model.add(BatchNormalization()) #layer13
convout4= Activation('relu')
model.add(convout4) #layer14
model.add(Conv1D(88,4,strides=2)) #layer15
model.add(ZeroPadding1D(padding=1))
model.add(BatchNormalization()) #layer16
convout5= Activation('relu')
model.add(convout5) #layer17
model.add(MaxPooling1D(pool_size=4,padding='valid')) #layer18
model.add(Conv1D(235,4,strides=2)) #layer15
model.add(ZeroPadding1D(padding=1))
model.add(BatchNormalization()) #layer16
convout6= Activation('relu')
model.add(convout6) #layer17
model.add(Conv1D(59,4,strides=2)) #layer18
model.add(ZeroPadding1D(padding=1))
model.add(BatchNormalization()) #layer19
convout7= Activation('relu')
model.add(convout7)
model.load_weights(weight_path)