public static Session Session(Graph graph) { return(new Session(graph)); }
public static void _run_using_default_session(Operation operation, FeedItem[] feed_dict, Graph graph, Session session) { if (session == null) { session = get_default_session(); if (session == null) { throw new ValueError("Cannot execute operation using `run()`: No default " + "session is registered. Use `with " + "sess.as_default():` or pass an explicit session to " + "`run(session=sess)`"); } } if (session.graph != graph) { throw new ValueError("Cannot use the default session to execute operation: " + "the operation's graph is different from the " + "session's graph. Pass an explicit session to " + "run(session=sess)."); } session.run(operation, feed_dict); }
/// <summary> /// Uses the default session to evaluate one or more tensors. /// </summary> /// <param name="tensors">A single Tensor, or a list of Tensor objects.</param> /// <param name="feed_dict"> /// A dictionary that maps Tensor objects (or tensor names) to lists, /// numpy ndarrays, TensorProtos, or strings. /// </param> /// <param name="graph">The graph in which the tensors are defined.</param> /// <param name="session">A different session to use to evaluate "tensors".</param> /// <returns> /// Either a single numpy ndarray if "tensors" is a single tensor; or a list /// of numpy ndarrays that each correspond to the respective element in /// "tensors". /// </returns> public static NDArray _eval_using_default_session(Tensor tensor, FeedItem[] feed_dict, Graph graph, Session session = null) { if (session == null) { session = get_default_session(); if (session == null) { throw new ValueError("Cannot evaluate tensor using `eval()`: No default " + "session is registered. Use `with " + "sess.as_default()` or pass an explicit session to " + "`eval(session=sess)`"); } if (session.graph != graph) { throw new ValueError("Cannot use the default session to evaluate tensor: " + "the tensor's graph is different from the session's " + "graph. Pass an explicit session to " + "`eval(session=sess)`."); } } else { if (session.graph != graph) { throw new ValueError("Cannot use the default session to evaluate tensor: " + "the tensor's graph is different from the session's " + "graph. Pass an explicit session to " + "`eval(session=sess)`."); } } return(session.run(tensor, feed_dict)); }
public static OpDef _get_op_def(Graph graph, string type) { return(graph.GetOpDef(type)); }
public static Graph set_default_graph(Graph graph) { //TODO: original source does not have a 'set_default_graph' and indicates there should be a _default_graph_stack! default_graph_stack.set_controller(graph); return(default_graph_stack.get_controller()); }
public string write_graph(Graph graph, string logdir, string name, bool as_text = true) => graph_io.write_graph(graph, logdir, name, as_text);