def get_weight(self, vshape, transpose=False, bias=True, name=''):
    try:
        idx_w = self.name_bank.index(('%s_w' % name))
        if bias:
            idx_b = self.name_bank.index(('%s_b' % name))
    except:
        w = tf.Variable(self.initializer_xavier(vshape), name=('%s_w' % name), trainable=True, dtype=tf.float32)
        self.name_bank.append(('%s_w' % name))
        self.params_trainable.append(w)
        tmpparams = 1
        for d in vshape:
            tmpparams *= d
        self.num_params += tmpparams
        if bias:
            if transpose:
                b = tf.Variable(self.initializer_xavier([vshape[(- 2)]]), name=('%s_b' % name), trainable=True, dtype=tf.float32)
            else:
                b = tf.Variable(self.initializer_xavier([vshape[(- 1)]]), name=('%s_b' % name), trainable=True, dtype=tf.float32)
            self.name_bank.append(('%s_b' % name))
            self.params_trainable.append(b)
            self.num_params += vshape[(- 2)]
    else:
        w = self.params_trainable[idx_w]
        if bias:
            b = self.params_trainable[idx_b]
    if bias:
        return (w, b)
    else:
        return w
def get_weight(self, vshape, transpose=False, bias=True, name=):
    try:
        idx_w = self.name_bank.index(('%s_w' % name))
        if bias:
            idx_b = self.name_bank.index(('%s_b' % name))
    except:
        w = tf.Variable(self.initializer_xavier(vshape), name=('%s_w' % name), trainable=True, dtype=tf.float32)
        self.name_bank.append(('%s_w' % name))
        self.params_trainable.append(w)
        tmpparams = 1
        for d in vshape:
            tmpparams *= d
        self.num_params += tmpparams
        if bias:
            if transpose:
                b = tf.Variable(self.initializer_xavier([vshape[(- 2)]]), name=('%s_b' % name), trainable=True, dtype=tf.float32)
            else:
                b = tf.Variable(self.initializer_xavier([vshape[(- 1)]]), name=('%s_b' % name), trainable=True, dtype=tf.float32)
            self.name_bank.append(('%s_b' % name))
            self.params_trainable.append(b)
            self.num_params += vshape[(- 2)]
    else:
        w = self.params_trainable[idx_w]
        if bias:
            b = self.params_trainable[idx_b]
    if bias:
        return (w, b)
    else:
        return w