コード例 #1
0
 def decode(self, q, name=None):
     qpoly = atu.polyexpand(q, self.Np_dec)
     N_coeff = atu.Npolyexpand( self.size_q, self.Np_dec )
     We1 = self._var("dec_W", (N_coeff, self.size_x) )
     be1 = self._var("dec_b", (self.size_x,) )
     x = tf.matmul( qpoly, We1 ) + be1
     return tf.identity(x,name=name)
コード例 #2
0
 def encode(self, x, name=None):
     N_coeff = atu.Npolyexpand( self.size_x, self.Np_enc )
     if self.encoder_init in encoder_init_options.keys():
         We1 = self._var("enc_W", (N_coeff, self.size_q),
                         initial_value = encoder_init_options[self.encoder_init])
     else:
         We1 = self._var("enc_W", (N_coeff, self.size_q) )
     be1 = self._var("enc_b", (self.size_q,) )
     q = tf.matmul( atu.polyexpand(x, self.Np_enc), We1 ) + be1
     return tf.identity(q,name=name)
コード例 #3
0
 def decode(self, q, name=None, phase_act="softmax"):
     qpoly = atu.polyexpand(q, self.Np_dec)
     N_coeff = atu.Npolyexpand( self.size_q, self.Np_dec )
     
     W1 = self._var("dec_W_curve", (N_coeff, self.N_curve, self.size_x) )
     b1 = self._var("dec_b_curve", (self.N_curve, self.size_x) )
     h_curve = tf.tensordot(qpoly,W1,axes=[-1,0])+b1
     
     h_select = self.classify(q,phase_act=phase_act)
     
     x = tf.einsum('ijk,ij->ik',h_curve,h_select)
     return tf.identity(x,name=name)
コード例 #4
0
    def classify(self, q, name=None, phase_act="softmax"):
        qpoly = atu.polyexpand(q, self.Np_dec)
        N_coeff = atu.Npolyexpand( self.size_q, self.Np_dec )

        W2 = self._var("dec_W_bound", (N_coeff, self.N_bound) )
        b2 = self._var("dec_b_bound", (self.N_bound,) )
        act = self.activations[self.boundary_activation]
        h_bound = act(tf.tensordot(qpoly,W2,axes=[-1,0])+b2)
        
        W_select = self._var("dec_W_select", (self.N_bound,self.N_curve))
        b_select = self._var("dec_b_select",(self.N_curve,))
        h_select = tf.tensordot(h_bound,W_select, axes=[-1,0]) + b_select
        if phase_act=="softmax":
            h_select = tf.nn.softmax(self.softmax_beta*h_select
                                     ,name=name)
        else:
            h_select = tf.one_hot(
                tf.argmax(h_select,axis=-1),
                depth=h_select.shape[-1],
                dtype=h_select.dtype,name=name)
            print("Did this.")
        return h_select
コード例 #5
0
 def encode(self, x, name=None):
     N_coeff = atu.Npolyexpand( self.size_x, self.Np_enc )
     W = self._var("enc_W", (N_coeff, self.size_q), 
                  initial_value=encoder_init_options[self.encoder_init])
     b = self._var("enc_b", (self.size_q,) )
     return tf.add(tf.matmul( atu.polyexpand(x, self.Np_enc), W ), b, name=name)
コード例 #6
0
 def decode(self, q, name=None):
     N_coeff = atu.Npolyexpand( self.size_q, self.Np_dec )
     nxt = atu.polyexpand(q, self.Np_dec)
     nxt = self._layers(nxt, self.dec_layers + [self.size_x], prefix="dec")
     return tf.identity(nxt, name=name)
コード例 #7
0
 def encode(self, x, name=None):
     N_coeff = atu.Npolyexpand( self.size_x, self.Np_enc )
     nxt = atu.polyexpand(x, self.Np_enc)
     nxt = self._layers(nxt, self.enc_layers + [self.size_q], prefix="enc")
     return tf.identity(nxt, name=name)