(self, *in_expr: TfExpression, return_as_list: bool = False, **dynamic_kwargs)
return out_expr
Construct TensorFlow expression(s) for the output(s) of this network, given the input expression(s).
Construct TensorFlow expression(s) for the output(s) of this network, given the input expression(s).
Construct TensorFlow expression ( s ) for the output ( s ) of this network given the input expression ( s ) .
def get_output_for(self, *in_expr: TfExpression, return_as_list: bool = False, **dynamic_kwargs) -> Union[TfExpression, List[TfExpression]]:
        """Construct TensorFlow expression(s) for the output(s) of this network, given the input expression(s)."""
        assert len(in_expr) == self.num_inputs
        assert not all(expr is None for expr in in_expr)

        # Finalize build func kwargs.
        build_kwargs = dict(self.static_kwargs)
        build_kwargs.update(dynamic_kwargs)
        build_kwargs["is_template_graph"] = False
        build_kwargs["components"] = self.components

        # Build TensorFlow graph to evaluate the network.
        with tfutil.absolute_variable_scope(self.scope, reuse=True), tf.name_scope(self.name):
            assert tf.get_variable_scope().name == self.scope
            valid_inputs = [expr for expr in in_expr if expr is not None]
            final_inputs = []
            for expr, name, shape in zip(in_expr, self.input_names, self.input_shapes):
                if expr is not None:
                    expr = tf.identity(expr, name=name)
                else:
                    expr = tf.zeros([tf.shape(valid_inputs[0])[0]] + shape[1:], name=name)
                final_inputs.append(expr)
            out_expr = self._build_func(*final_inputs, **build_kwargs)

        # Propagate input shapes back to the user-specified expressions.
        for expr, final in zip(in_expr, final_inputs):
            if isinstance(expr, tf.Tensor):
                expr.set_shape(final.shape)

        # Express outputs in the desired format.
        assert tfutil.is_tf_expression(out_expr) or isinstance(out_expr, tuple)
        if return_as_list:
            out_expr = [out_expr] if tfutil.is_tf_expression(out_expr) else list(out_expr)
        return out_expr
def get_output_for ( self , * in_expr : TfExpression , return_as_list : bool = False , * * dynamic_kwargs ) -> Union [ TfExpression , List [ TfExpression ] ] : assert len ( in_expr ) == self . num_inputs assert not all ( expr is None for expr in in_expr ) # Finalize build func kwargs. build_kwargs = dict ( self . static_kwargs ) build_kwargs . update ( dynamic_kwargs ) build_kwargs [ "is_template_graph" ] = False build_kwargs [ "components" ] = self . components # Build TensorFlow graph to evaluate the network. with tfutil . absolute_variable_scope ( self . scope , reuse = True ) , tf . name_scope ( self . name ) : assert tf . get_variable_scope ( ) . name == self . scope valid_inputs = [ expr for expr in in_expr if expr is not None ] final_inputs = [ ] for expr , name , shape in zip ( in_expr , self . input_names , self . input_shapes ) : if expr is not None : expr = tf . identity ( expr , name = name ) else : expr = tf . zeros ( [ tf . shape ( valid_inputs [ 0 ] ) [ 0 ] ] + shape [ 1 : ] , name = name ) final_inputs . append ( expr ) out_expr = self . _build_func ( * final_inputs , * * build_kwargs ) # Propagate input shapes back to the user-specified expressions. for expr , final in zip ( in_expr , final_inputs ) : if isinstance ( expr , tf . Tensor ) : expr . set_shape ( final . shape ) # Express outputs in the desired format. assert tfutil . is_tf_expression ( out_expr ) or isinstance ( out_expr , tuple ) if return_as_list : out_expr = [ out_expr ] if tfutil . is_tf_expression ( out_expr ) else list ( out_expr ) return out_expr