MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / ConvPoolLayer

Class ConvPoolLayer

cnn_class/cifar.py:84–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84class ConvPoolLayer(object):
85 def __init__(self, mi, mo, fw=5, fh=5, poolsz=(2, 2)):
86 # mi = input feature map size
87 # mo = output feature map size
88 sz = (mo, mi, fw, fh)
89 W0 = init_filter(sz, poolsz)
90 self.W = theano.shared(W0)
91 b0 = np.zeros(mo, dtype=np.float32)
92 self.b = theano.shared(b0)
93 self.poolsz = poolsz
94 self.params = [self.W, self.b]
95
96 def forward(self, X):
97 conv_out = conv2d(input=X, filters=self.W)
98 pooled_out = downsample.max_pool_2d(
99 input=conv_out,
100 ds=self.poolsz,
101 ignore_border=True
102 )
103 return T.nnet.relu(pooled_out + self.b.dimshuffle('x', 0, 'x', 'x'))
104
105
106class CNN(object):

Callers 1

fitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected