1. Create a session, start a session

import tensorflow as tf
# Create a constant 
M1 = tf.constant ([[3,3 ]])
 # Create a constant 
M2 = tf.constant ([[2], [. 3 ]])
 # matrix multiplication OP 
Product = tf.matmul (M1, M2)
 Print (Product)
# Define the session 
sess = tf.Session ()
 # calls the run method sess performs matrix multiplication of OP 
Result = sess.run (Product)
 Print (Result) 
sess.close ()
tf.Session with () AS sess:
     # calls the run method sess in to perform matrix multiplication OP 
    the Result = sess.run (Product)
     Print (the Result)

 

Guess you like

Origin www.cnblogs.com/liuwenhua/p/11605287.html