deep-learning-from-scratch
deep-learning-from-scratch copied to clipboard
deep_convnet.py
in deep_convnet.py
pre_node_nums = np.array([1*3*3, 16*3*3, 16*3*3, 32*3*3, 32*3*3, 64*3*3, 64*4*4, hidden_size])
how to compute the neurons number in each convolution layer? why not pre_node_nums = np.array([1*3*3, 16, 16, 32, 32, 64, 64*4*4, hidden_size]
thanks
Hey bro, If I'm not wrong, I think the pre_node_num is decided by yours, no matter you what value you assign, the code can run successfully ang get a suitable result. However, it is noteworthy that the self.params['W7'] = wight_init_scales[6] * np.random.randn(64 * 4 * 4, hidden_size)
should be paid more anttention to calculate, cus I spent a long time to find that how to calculate the final result.
The result should folow the order of layer, and the feature map size will be changed accoding to the pooling and convolution layer:
`self.layers = []
self.layers.append(Convolution(self.params['W1'], self.params['b1'],
conv_param_1['stride'], conv_param_1['pad']))
self.layers.append(Relu())
self.layers.append(Convolution(self.params['W2'], self.params['b2'],
conv_param_2['stride'], conv_param_2['pad']))
self.layers.append(Relu())
self.layers.append(Pooling(pool_h=2, pool_w=2, stride=2))
self.layers.append(Convolution(self.params['W3'], self.params['b3'],
conv_param_3['stride'], conv_param_3['pad']))
self.layers.append(Relu())
self.layers.append(Convolution(self.params['W4'], self.params['b4'],
conv_param_4['stride'], conv_param_4['pad']))
self.layers.append(Relu())
self.layers.append(Pooling(pool_h=2, pool_w=2, stride=2))
self.layers.append(Convolution(self.params['W5'], self.params['b5'],
conv_param_5['stride'], conv_param_5['pad']))
self.layers.append(Relu())
self.layers.append(Convolution(self.params['W6'], self.params['b6'],
conv_param_6['stride'], conv_param_6['pad']))
self.layers.append(Relu())
self.layers.append(Pooling(pool_h=2, pool_w=2, stride=2))
self.layers.append(Affine(self.params['W7'], self.params['b7']))
self.layers.append(Relu())
self.layers.append(Dropout(0.5))
self.layers.append(Affine(self.params['W8'], self.params['b8']))
self.layers.append(Dropout(0.5))`