回答編集履歴

1

コード追加

2021/03/26 00:33

投稿

jbpb0
jbpb0

スコア7651

test CHANGED
@@ -14,9 +14,13 @@
14
14
 
15
15
 
16
16
 
17
+
18
+
19
+ # tf.constant
20
+
17
21
  #a = tf.constant([[1, 2], [3, 4]])
18
22
 
19
- a = tf.constant(np.arange(1, 13, dtype=np.int32), shape=[2, 2, 3])
23
+ a = tf.constant([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
20
24
 
21
25
  print(type(a))
22
26
 
@@ -42,4 +46,44 @@
42
46
 
43
47
  print(type(a_np2))
44
48
 
49
+
50
+
51
+
52
+
53
+ # tf.Variable
54
+
55
+ #b = tf.Variable([[1, 2], [3, 4]])
56
+
57
+ b = tf.Variable([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
58
+
59
+ print(type(b))
60
+
61
+
62
+
63
+ sess = tf.Session()
64
+
65
+ sess.run(tf.global_variables_initializer())
66
+
67
+ b_np = b.eval(sess)
68
+
69
+ print(b_np)
70
+
71
+ print(b_np.shape)
72
+
73
+ print(type(b_np))
74
+
75
+
76
+
77
+ sess2 = tf.Session()
78
+
79
+ sess2.run(tf.global_variables_initializer())
80
+
81
+ b_np2 = sess2.run(b)
82
+
83
+ print(b_np2)
84
+
85
+ print(b_np2.shape)
86
+
87
+ print(type(b_np2))
88
+
45
89
  ```