def fprop(self, hidden): convout = conv1d_oversample.conv1d_down( input=hidden, filters=self.W, filter_shape=self.filter_shape, image_shape=(self.batch_size, self.input_shape[1], self.input_shape[2], self.input_shape[3]), stride=self.stride, border_mode="headless", ) linout = convout + self.b.dimshuffle("x", 0, "x", "x") if self.activation == "tanh": actout = T.tanh(linout) elif self.activation == "lin": actout = linout elif self.activation == "relu": actout = linout * (linout > 0.0) + 0.0 * (linout < 0.0) else: raise ValueError("Invalid activation") return actout
def encode(self, hidden): convout = conv1d_oversample.conv1d_down( input=hidden, filters=self.W, filter_shape=self.filter_shape, image_shape=(self.batch_size, self.input_shape[1], self.input_shape[2], self.input_shape[3]), stride=self.stride, border_mode='headless') linout = convout + self.b.dimshuffle('x', 0, 'x', 'x') if self.dec_hid == 'tanh': actout = T.tanh(linout) elif self.dec_hid == 'lin': actout = linout elif self.dec_hid == 'relu': actout = linout * (linout > 0.0) + 0.0 * (linout < 0.0) else: raise ValueError('Invalid dec_hid') return actout
x = T.vector() x_re = x.reshape(image_shape) w = theano.shared(np.asarray(np.ones(filter_shape),dtype=theano.config.floatX)) y = conv1d_oversample.conv1d(x_re,w,image_shape,filter_shape,stride=stride,border_mode='full') fun = theano.function([x],y) inp = np.asarray(np.ones(image_shape[3]),dtype=theano.config.floatX) print 'input', inp print 'filter', w.get_value().flatten() print 'stride', stride print 'output', fun(inp).flatten() ''' image_shape=(1,10,1,256) filter_shape=(1,10,1,25) stride=16 x = T.vector() x_re = x.reshape(image_shape) w = theano.shared(np.asarray(np.ones(filter_shape),dtype=theano.config.floatX)) y = conv1d_oversample.conv1d_down(x_re,w,stride=stride,border_mode='full') #y = conv1d_oversample.conv1d_down(x_re,w,image_shape,filter_shape,stride=stride,border_mode='full') fun = theano.function([x],y) inp = np.asarray(np.ones(np.prod(image_shape)),dtype=theano.config.floatX) print 'input', inp print 'filter', w.get_value().flatten() print 'stride', stride print 'output', fun(inp).flatten()