回答編集履歴
1
コード追加
    
        answer	
    CHANGED
    
    | @@ -6,8 +6,10 @@ | |
| 6 6 | 
             
            import tensorflow as tf
         | 
| 7 7 | 
             
            import numpy as np
         | 
| 8 8 |  | 
| 9 | 
            +
             | 
| 10 | 
            +
            # tf.constant
         | 
| 9 11 | 
             
            #a = tf.constant([[1, 2], [3, 4]])
         | 
| 10 | 
            -
            a = tf.constant( | 
| 12 | 
            +
            a = tf.constant([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
         | 
| 11 13 | 
             
            print(type(a))
         | 
| 12 14 |  | 
| 13 15 | 
             
            tf.InteractiveSession()
         | 
| @@ -20,4 +22,24 @@ | |
| 20 22 | 
             
            print(a_np2)
         | 
| 21 23 | 
             
            print(a_np2.shape)
         | 
| 22 24 | 
             
            print(type(a_np2))
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
            # tf.Variable
         | 
| 28 | 
            +
            #b = tf.Variable([[1, 2], [3, 4]])
         | 
| 29 | 
            +
            b = tf.Variable([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
         | 
| 30 | 
            +
            print(type(b))
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            sess = tf.Session()
         | 
| 33 | 
            +
            sess.run(tf.global_variables_initializer())
         | 
| 34 | 
            +
            b_np = b.eval(sess)
         | 
| 35 | 
            +
            print(b_np)
         | 
| 36 | 
            +
            print(b_np.shape)
         | 
| 37 | 
            +
            print(type(b_np))
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            sess2 = tf.Session()
         | 
| 40 | 
            +
            sess2.run(tf.global_variables_initializer())
         | 
| 41 | 
            +
            b_np2 = sess2.run(b)
         | 
| 42 | 
            +
            print(b_np2)
         | 
| 43 | 
            +
            print(b_np2.shape)
         | 
| 44 | 
            +
            print(type(b_np2))
         | 
| 23 45 | 
             
            ```
         | 
