示例#1
0
    def build(self):
        """ Construct internal trainable weights.
    """
        self.W = []
        n_size = self.n_size
        for i in range(n_size):
            if i < np.floor(n_size / 2):
                W_effective = tf.Variable(tf.zeros(
                    (n_size, self.n_input_feat, self.n_output_feat)),
                                          trainable=False)
            else:
                W_trainable = self.init(
                    [n_size - i, self.n_input_feat, self.n_output_feat])
                W_before = tf.Variable(tf.zeros(
                    (i - int(np.floor(n_size / 2.)), self.n_input_feat,
                     self.n_output_feat)),
                                       trainable=False)
                W_after = tf.Variable(tf.zeros(
                    (int(np.floor(n_size / 2.)), self.n_input_feat,
                     self.n_output_feat)),
                                      trainable=False)
                W_effective = tf.concat([W_before, W_trainable, W_after], 0)
            self.W.append(W_effective)

        self.W = tf.stack(self.W, axis=0)
        self.b = model_ops.zeros((self.n_output_feat, ))
        self.trainable_weights = [self.W, self.b]
示例#2
0
 def build(self):
     self.W_effective = self.init(
         [self.n_size, self.n_input_feat, self.n_output_feat])
     self.W = []
     for i in range(self.n_size):
         self.W.append(self.W_effective[i:i + 1, :, :])
         if i < self.n_size - 1:
             self.W.append(
                 tf.Variable(tf.zeros((self.rate - 1, self.n_input_feat,
                                       self.n_output_feat)),
                             trainable=False))
     self.W = tf.concat(self.W, 0)
     self.b = model_ops.zeros((self.n_output_feat, ))
     self.trainable_weights = [self.W, self.b]
示例#3
0
 def build(self):
     self.W = self.init(
         [self.n_size, self.n_size, self.n_output_feat, self.n_input_feat])
     self.b = model_ops.zeros((self.n_output_feat, ))
     self.trainable_weights = [self.W, self.b]