Ejemplo n.º 1
0
    def output(self, x):
        # non-linear transform of the convolution output
        conv_out = conv2d(x, self.W, mode="full")

        if self.fold_flag:
            # fold
            fold_out = self.fold(conv_out)
        else:
            fold_out = conv_out

        # k-max pool
        pool_out = (self.k_max_pool(fold_out, self.k) +
                    self.b[np.newaxis, :, np.newaxis, np.newaxis])

        return np.tanh(pool_out)
Ejemplo n.º 2
0
    def output(self, x):
        # non-linear transform of the convolution output
        conv_out = conv2d(x, 
                          self.W, 
                          mode = "full")                     
        
        if self.fold_flag:
            # fold
            fold_out = self.fold(conv_out)
        else:
            fold_out = conv_out

        # k-max pool        
        pool_out = (self.k_max_pool(fold_out, self.k) + 
                    self.b[np.newaxis, :, np.newaxis, np.newaxis])
        
        return np.tanh(pool_out)
Ejemplo n.º 3
0
from numpy_impl import conv2d

from test_util import assert_matrix_eq

########################
# Numpy part #
########################

feature_n_prev = 3

input_feature_map = np.random.rand(2, feature_n_prev, 2, 2)

# shape: (2,3,2,2)
filters = np.random.rand(2, feature_n_prev, 2, 2)

numpy_output = conv2d(input_feature_map, filters)
print numpy_output

########################
# Theano part#
########################

import theano

input_feature_map_sym = theano.tensor.dtensor4("input_feature_map")
filters_sym = theano.tensor.dtensor4("filters")

f = theano.function(
    inputs=[input_feature_map_sym, filters_sym],
    outputs=theano.tensor.nnet.conv.conv2d(input_feature_map_sym,
                                           filters_sym,
Ejemplo n.º 4
0
from numpy_impl import conv2d

from test_util import assert_matrix_eq

########################
# Numpy part #
########################
        
feature_n_prev = 3

input_feature_map = np.random.rand(2,feature_n_prev,2,2)

# shape: (2,3,2,2)
filters = np.random.rand(2,feature_n_prev,2,2)

numpy_output = conv2d(input_feature_map, filters)
print numpy_output

########################
# Theano part#
########################

import theano

input_feature_map_sym = theano.tensor.dtensor4("input_feature_map")
filters_sym = theano.tensor.dtensor4("filters")

f = theano.function(inputs = [input_feature_map_sym, filters_sym], 
                    outputs = theano.tensor.nnet.conv.conv2d(input_feature_map_sym, 
                                                             filters_sym, 
                                                             border_mode = "full")