(self, points)
return values
Build the evaluation graph.
Build the evaluation graph.
Build the evaluation graph .
def build_evaluation(self, points):
        """Build the evaluation graph."""
        net = points
        if isinstance(net, np.ndarray):
            net = tf.constant(net)
        for i in range(self.num_layers):
            if i == 0:
                layer_input_dim = self.input_dim
            else:
                layer_input_dim = self.output_dims[i - 1]
            W = tf.get_variable('weights_posdef_{}'.format(i), [self.hidden_dims[i], layer_input_dim], TF_DTYPE, self.initializer)
            kernel = tf.matmul(W, W, transpose_a=True) + self.eps * tf.eye(layer_input_dim, dtype=TF_DTYPE)
            dim_diff = self.output_dims[i] - layer_input_dim
            if dim_diff > 0:
                W = tf.get_variable('weights_{}'.format(i), [dim_diff, layer_input_dim], TF_DTYPE, self.initializer)
                kernel = tf.concat([kernel, W], axis=0)
            layer_output = tf.matmul(net, kernel, transpose_b=True)
            net = self.activations[i](layer_output, name='layer_output_{}'.format(i))
        values = tf.reduce_sum(tf.square(net), axis=1, keepdims=True, name='quadratic_form')
        return values
def build_evaluation ( self , points ) : net = points if isinstance ( net , np . ndarray ) : net = tf . constant ( net ) for i in range ( self . num_layers ) : if i == 0 : layer_input_dim = self . input_dim else : layer_input_dim = self . output_dims [ i - 1 ] W = tf . get_variable ( 'weights_posdef_{}' . format ( i ) , [ self . hidden_dims [ i ] , layer_input_dim ] , TF_DTYPE , self . initializer ) kernel = tf . matmul ( W , W , transpose_a = True ) + self . eps * tf . eye ( layer_input_dim , dtype = TF_DTYPE ) dim_diff = self . output_dims [ i ] - layer_input_dim if dim_diff > 0 : W = tf . get_variable ( 'weights_{}' . format ( i ) , [ dim_diff , layer_input_dim ] , TF_DTYPE , self . initializer ) kernel = tf . concat ( [ kernel , W ] , axis = 0 ) layer_output = tf . matmul ( net , kernel , transpose_b = True ) net = self . activations [ i ] ( layer_output , name = 'layer_output_{}' . format ( i ) ) values = tf . reduce_sum ( tf . square ( net ) , axis = 1 , keepdims = True , name = 'quadratic_form' ) return values