def get_weights_topo(self): if not isinstance(self.input_space, Conv2DSpace): raise NotImplementedError() W, = self.transformer.get_params() W = W.T W = W.reshape((self.detector_layer_dim, self.input_space.shape[0], self.input_space.shape[1], self.input_space.nchannels)) W = Conv2DSpace.convert(W, self.input_space.axes, ('b', 0, 1, 'c')) return function([], W)()
def get_weights_topo(self): if not isinstance(self.input_space, Conv2DSpace): raise NotImplementedError() W ,= self.transformer.get_params() W = W.T W = W.reshape((self.dim, self.input_space.shape[0], self.input_space.shape[1], self.input_space.nchannels)) W = Conv2DSpace.convert(W, self.input_space.axes, ('b', 0, 1, 'c')) return function([], W)()
def get_weights_topo(self): warnings.warn("BoltzmannIsingHidden.get_weights_topo returns the BOLTZMANN weights, is that what we want?") if not isinstance(self.input_space, Conv2DSpace): raise NotImplementedError() W = self.W W = W.T W = W.reshape((self.detector_layer_dim, self.input_space.shape[0], self.input_space.shape[1], self.input_space.nchannels)) W = Conv2DSpace.convert(W, self.input_space.axes, ('b', 0, 1, 'c')) return function([], W)()
def expr(self, model, data, **kwargs): space, sources = self.get_data_specs(model) space.validate(data) (X, Y) = data input_space = model.get_input_space() output_space = model.get_output_space() X = Conv2DSpace.convert(X, input_space.axes, output_space.axes) Y = Y.reshape((Y.shape[0], output_space.num_channels, output_space.shape[0], output_space.shape[1])) Y_hat = X[:, -1, (input_space.shape[0] - output_space.shape[0]) / 2:(input_space.shape[0] - output_space.shape[0]) / 2 + output_space.shape[0], (input_space.shape[1] - output_space.shape[1]) / 2:(input_space.shape[1] - output_space.shape[1]) / 2 + output_space.shape[1], ] Y_hat = Y_hat.dimshuffle(0, 'x', 1, 2) return T.sqr(Y - Y_hat).sum(axis=(1, 2, 3)).mean()
def expr(self, model, data, ** kwargs): space, sources = self.get_data_specs(model) space.validate(data) (X, Y) = data input_space = model.get_input_space() output_space = model.get_output_space() X = Conv2DSpace.convert(X, input_space.axes, output_space.axes) Y = Y.reshape((Y.shape[0], output_space.num_channels, output_space.shape[0], output_space.shape[1])) Y_hat = X[:, -1, (input_space.shape[0]-output_space.shape[0])/2: (input_space.shape[0]-output_space.shape[0])/2+output_space.shape[0], (input_space.shape[1]-output_space.shape[1])/2: (input_space.shape[1]-output_space.shape[1])/2+output_space.shape[1], ] Y_hat = Y_hat.dimshuffle(0, 'x', 1, 2) return T.sqr(Y - Y_hat).sum(axis=(1,2,3)).mean()