-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemp.py
64 lines (48 loc) · 2.33 KB
/
temp.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
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 30 20:59:39 2018
@author: lekha
"""
from keras.models import Sequential
from keras.layers.convolutional import Conv2D
from keras.layers import MaxPooling2D
from keras.layers.core import Activation
from keras.layers.core import Flatten
from keras.layers.core import Dense
from keras import backend
backend.set_image_dim_ordering('tf')
class NeuralNet:
def build(self, no_of_items, width, height, depth, total_classes, Saved_Weights_Path=None):
model = Sequential()
model.add(Conv2D(140, 5, 5, border_mode="same", input_shape=(height, width, depth)))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), dim_ordering="tf"))
model.add(Conv2D(120, 5, 5, border_mode="same"))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), dim_ordering="tf"))
model.add(Conv2D(100, 5, 5, border_mode="same"))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), dim_ordering="tf"))
model.add(Conv2D(100, 5, 5, border_mode="same"))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), dim_ordering="tf"))
model.add(Conv2D(100, 5, 5, border_mode="same"))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), dim_ordering="tf"))
model.add(Conv2D(90, 5, 5, border_mode="same"))
model.add(Activation("relu"))
#model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), dim_ordering="tf"))
model.add(Conv2D(90, 5, 5, border_mode="same"))
model.add(Activation("relu"))
#model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), dim_ordering="tf"))
model.add(Conv2D(80, 5, 5, border_mode="same"))
model.add(Activation("relu"))
#model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2), dim_ordering="tf"))
model.add(Flatten())
model.add(Dense(500))
model.add(Activation("relu"))
model.add(Dense(total_classes))
model.add(Activation("softmax"))
if Saved_Weights_Path is not None:
model.load_weights(Saved_Weights_Path)
return model