コード例 #1
0
ファイル: AE_archs.py プロジェクト: mpslxz/DNM
    def _decode(self, X, init_params):
        params = []
        regs = []
        d4, pars = Ops.dense(X,
                             self.latent_size,
                             self.input_size[0] * self.input_size[1] * 5,
                             layer_name='d4',
                             init_params=get_params('d4', init_params))
        params += pars
        regs.append(pars[0])
        d4 = T.reshape((d4), (-1, 5, self.input_size[0], self.input_size[1]))

        d3, pars = Ops.conv_2d(activations.relu(d4), (8, 5, 5, 5),
                               layer_name='d3',
                               mode='half',
                               init_params=get_params('d3', init_params))
        params += pars
        regs.append(pars[0])
        d2, pars = Ops.conv_2d(activations.relu(d3), (10, 8, 5, 5),
                               layer_name='d2',
                               mode='half',
                               init_params=get_params('d2', init_params))
        params += pars
        regs.append(pars[0])
        d1, pars = Ops.conv_2d(activations.relu(d2), (1, 10, 5, 5),
                               layer_name='d1',
                               mode='half',
                               init_params=get_params('d1', init_params))
        params += pars
        regs.append(pars[0])
        return activations.sigmoid(d1), params, regs
コード例 #2
0
ファイル: AE_archs.py プロジェクト: mpslxz/DNM
 def _encode(self, X, init_params):
     params = []
     regs = []
     e1, pars = Ops.conv_2d(X, (10, 1, 5, 5),
                            layer_name='e1',
                            mode='half',
                            init_params=get_params('e1', init_params))
     params += pars
     regs.append(pars[0])
     e2, pars = Ops.conv_2d(activations.relu(e1), (8, 10, 5, 5),
                            layer_name='e2',
                            mode='half',
                            init_params=get_params('e2', init_params))
     params += pars
     regs.append(pars[0])
     e3, pars = Ops.conv_2d(activations.relu(e2), (5, 8, 5, 5),
                            layer_name='e3',
                            mode='half',
                            init_params=get_params('e3', init_params))
     params += pars
     regs.append(pars[0])
     e4, pars = Ops.dense(Ops.flatten(activations.relu(e3)),
                          self.input_size[0] * self.input_size[1] * 5,
                          self.latent_size,
                          layer_name='e4',
                          init_params=get_params('e4', init_params))
     params += pars
     regs.append(pars[0])
     return e4, params, regs
コード例 #3
0
ファイル: archs.py プロジェクト: mpslxz/icvae
def _conv_block(x, nb_filters, nb_channels, filter_size, block_idx, theano_model, double=True, init_params=None):
    params = []
    to_reg = []

    layer, pars = conv_2d(
        x, (nb_filters, nb_channels, filter_size,
            filter_size), layer_name=str(block_idx) + 'l1',
        init_params=theano_model.get_params(str(block_idx) + 'l1', param_list=init_params))
    params += pars
    to_reg.append(pars[0])

    layer, pars = bn(layer, trainable=True, layer_name=str(block_idx) + 'bn1',
                     init_params=theano_model.get_params(
                         str(block_idx) + 'bn1',
                     param_list=init_params))
    params += pars

    if double:
        layer, pars = conv_2d(
            layer, (2 * nb_filters, nb_filters, filter_size, filter_size), layer_name=str(block_idx) + 'l2',
            init_params=theano_model.get_params(str(block_idx) + 'l2', param_list=init_params))
        params += pars
        to_reg.append(pars[0])

    else:
        layer, pars = conv_2d(
            layer, (nb_filters, nb_filters, filter_size,
                    filter_size), layer_name=str(block_idx) + 'l2',
            init_params=theano_model.get_params(str(block_idx) + 'l2', param_list=init_params))
        params += pars
        to_reg.append(pars[0])
    return relu(layer), params, to_reg
コード例 #4
0
ファイル: archs.py プロジェクト: mpslxz/icvae
def accgan_deconv(x, theano_model, input_channels, nb_filters, layer_name, init_params, filter_size=3, stride=(1,1), batch_norm=True, dropout_prob=0.2):
    params = []
    regs = []
    l = T.nnet.abstract_conv.bilinear_upsampling(x, ratio=2)
    l, pars = conv_2d(l, (nb_filters, input_channels, filter_size, filter_size),
                      layer_name=layer_name,
                      mode='half',
                      stride=stride,
                      init_params=theano_model.get_params(layer_name, init_params))
    params += pars
    regs.append(pars[0])
    if batch_norm:
        l, pars = bn(inpt=l, trainable=True, layer_name=layer_name, init_params=theano_model.get_params(layer_name, init_params))
        params += pars


    l, pars = conv_2d(l, (nb_filters, nb_filters, filter_size, filter_size),
                      layer_name=layer_name+'second',
                      mode='half',
                      stride=stride,
                      init_params=theano_model.get_params(layer_name+'second', init_params))
    params += pars
    regs.append(pars[0])
    if batch_norm:
        l, pars = bn(inpt=l, trainable=True, layer_name=layer_name+'second', init_params=theano_model.get_params(layer_name+'second', init_params))
        params += pars
    l = dropout(relu(l), dropout_prob)
    return l, params, regs
コード例 #5
0
ファイル: gen_configs.py プロジェクト: mpslxz/icvae
 def label_encoder(self, x):
     code, _par = dense(flatten(x), self.class_label_size, self.encoded_label_size,
                        layer_name='omega', init_params=self.get_params('omega', self.init_params))
     code = relu(code)
     self.params += _par
     self.to_regularize.append(_par[0])
     return code
コード例 #6
0
ファイル: archs.py プロジェクト: mpslxz/icvae
def accgan_conv(x, theano_model, input_channels, nb_filters, layer_name, init_params, filter_size=3, stride=(1,1), batch_norm=True, dropout_prob=0.2):
    params = []
    regs = []
    l, pars = conv_2d(x, (nb_filters, input_channels, filter_size, filter_size),
                      layer_name=layer_name,
                      mode='half',
                      stride=stride,
                      init_params=theano_model.get_params(layer_name, init_params))
    params += pars
    regs.append(pars[0])
    if batch_norm:
        l, pars = bn(inpt=l, trainable=True, layer_name=layer_name, init_params=theano_model.get_params(layer_name, init_params))
        params += pars
    l = dropout(relu(l), dropout_prob)
    return l, params, regs