 DeepLearning - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Programming : DeepLearning Package : DeepLearning Types : DeepLearning/SessionObject

DeepLearning

 SessionObject
 object for DeepLearning computation session

Description

 • A Session is an object which encapsulates the context in which Tensor objects within a DataflowGraph are evaluated.
 • There can be more than one Session for the same DataflowGraph, and each Session has its own state and resources.

Creating and Using Sessions

 • To obtain the default computation session for the current graph, use the GetDefaultSession command.
 • To obtain a new session, use the Session command.

Operations with Sessions

 • The following functions can be performed with a Session.

Examples

Here we execute the same simple graph (which performs arithmetic with three Tensors) in the default computation session and in a new session.

 > $\mathrm{with}\left(\mathrm{DeepLearning}\right):$
 > $\mathrm{t1}≔\mathrm{Variable}\left(\left[1.5,2.0\right],\mathrm{datatype}=\mathrm{float}\left[8\right]\right)$
 ${\mathrm{t1}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Tensor}}\\ {\mathrm{Name: Variable:0}}\\ {\mathrm{Shape: \left[2\right]}}\\ {\mathrm{Data Type: float\left[8\right]}}\end{array}\right]$ (1)
 > $\mathrm{t2}≔\mathrm{Variable}\left(\left[2.5,6.0\right],\mathrm{datatype}=\mathrm{float}\left[8\right]\right)$
 ${\mathrm{t2}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Tensor}}\\ {\mathrm{Name: Variable_1:0}}\\ {\mathrm{Shape: \left[2\right]}}\\ {\mathrm{Data Type: float\left[8\right]}}\end{array}\right]$ (2)
 > $\mathrm{t3}≔\mathrm{Variable}\left(\left[7.2,4.2\right],\mathrm{datatype}=\mathrm{float}\left[8\right]\right)$
 ${\mathrm{t3}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Tensor}}\\ {\mathrm{Name: Variable_2:0}}\\ {\mathrm{Shape: \left[2\right]}}\\ {\mathrm{Data Type: float\left[8\right]}}\end{array}\right]$ (3)
 > $\mathrm{init}≔\mathrm{VariablesInitializer}\left(\right)$
 ${\mathrm{init}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Tensor}}\\ {\mathrm{Name: init}}\\ {\mathrm{Shape: undefined}}\\ {\mathrm{Data Type: undefined}}\end{array}\right]$ (4)
 > $\mathrm{dft_sess}≔\mathrm{GetDefaultSession}\left(\right)$
 ${\mathrm{dft_sess}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Session}}\\ {\mathrm{}}\end{array}\right]$ (5)
 > $\mathrm{dft_sess}:-\mathrm{Run}\left(\mathrm{init}\right)$
 ${\mathrm{Python}}{:-}{\mathrm{None}}$ (6)
 > $\mathrm{dft_sess}:-\mathrm{Run}\left(\mathrm{t1}\mathrm{t2}+\mathrm{t3}\right)$
 $\left[\begin{array}{c}{10.9500000000000}\\ {16.2000000000000}\end{array}\right]$ (7)
 > $\mathrm{new_sess}≔\mathrm{Session}\left(\right)$
 ${\mathrm{new_sess}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Session}}\\ {\mathrm{}}\end{array}\right]$ (8)
 > $\mathrm{new_sess}:-\mathrm{Run}\left(\mathrm{init}\right)$
 ${\mathrm{Python}}{:-}{\mathrm{None}}$ (9)
 > $\mathrm{new_sess}:-\mathrm{Run}\left(\mathrm{t1}\mathrm{t2}+\mathrm{t3}\right)$
 $\left[\begin{array}{c}{10.9500000000000}\\ {16.2000000000000}\end{array}\right]$ (10)

Compatibility

 • The DeepLearning[SessionObject] command was introduced in Maple 2018.
 • For more information on Maple 2018 changes, see Updates in Maple 2018.

 See Also