-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_predict_net.py
More file actions
73 lines (58 loc) · 2.19 KB
/
Copy pathmake_predict_net.py
File metadata and controls
73 lines (58 loc) · 2.19 KB
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
from utilities import float32,get_image_from_url
import cPickle as pickle
import theano
from lasagne import layers
from lasagne.updates import sgd
from lasagne.nonlinearities import rectify
from lasagne.layers import InputLayer, DenseLayer, DropoutLayer
from lasagne.layers.dnn import Conv2DDNNLayer as ConvLayer
from lasagne.layers.dnn import Pool2DDNNLayer as PoolLayer
from nolearn.lasagne import NeuralNet
def define_net(image_shape = (None,3,120,120),name='neural_net',verbose = 1):
'''
make neural net that has no dropout or classification layers, but is
otherwise identical to the is it a tattoo or nor trained network
'''
net = NeuralNet(
layers =[
('input', InputLayer),
('conv1', ConvLayer),
('pool1', PoolLayer),
('conv2', ConvLayer),
('pool2', PoolLayer),
('conv3', ConvLayer),
('pool3', PoolLayer),
('conv4', ConvLayer),
('pool4', PoolLayer),
('hidden5', DenseLayer),
('hidden6', DenseLayer),
('hidden7', DenseLayer),
],
input_shape = image_shape,
conv1_num_filters = 40, conv1_filter_size = (15,15),
pool1_pool_size = (2,2),
conv2_num_filters = 108, conv2_filter_size = (8,8),
pool2_pool_size = (2,2),
conv3_num_filters = 260, conv3_filter_size = (3,3),
pool3_pool_size = (2,2),
conv4_num_filters = 572, conv4_filter_size = (2,2),
pool4_pool_size = (2,2),
hidden5_num_units = 500,
hidden6_num_units = 500,
hidden7_num_units = 250,
hidden7_nonlinearity = rectify,
update = sgd,
update_learning_rate = theano.shared(float32(0.05)),
regression = False,
max_epochs = 2000,
verbose = verbose,
)
return net
if __name__ == '__main__':
# define net with no classification layer
net = define_net()
# load in best parameters
net.load_params_from('featurize_params.pkl')
# save featurization network
with open('featurize_net.pkl','wb') as f:
pickle.dump(net,f)