質問編集履歴
2
normalのスペルミスを訂正し、加筆しましたあ。
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,19 +92,15 @@
|
|
92
92
|
|
93
93
|
|
94
94
|
|
95
|
-
|
95
|
+
nomal→normalに訂正したところ、
|
96
96
|
|
97
97
|
|
98
98
|
|
99
99
|
```
|
100
100
|
|
101
|
-
>>> import tensorflow as tf
|
102
|
-
|
103
|
-
>>>
|
104
|
-
|
105
101
|
>>> def weight(shape = []):
|
106
102
|
|
107
|
-
... initial = tf.truncated_nomal(shape, stddev = 0.01)
|
103
|
+
... initial = tf.truncated_normal(shape, stddev = 0.01)
|
108
104
|
|
109
105
|
... return tf.Variable(initial)
|
110
106
|
|
@@ -126,26 +122,76 @@
|
|
126
122
|
|
127
123
|
>>> W = weight(shape = [Q,P])
|
128
124
|
|
129
|
-
Traceback (most recent call last):
|
130
|
-
|
131
|
-
File "<stdin>", line 1, in <module>
|
132
|
-
|
133
|
-
File "<stdin>", line 2, in weight
|
134
|
-
|
135
|
-
AttributeError: module 'tensorflow' has no attribute 'truncated_nomal'
|
136
|
-
|
137
125
|
>>> b = bias(shape = [P])
|
138
126
|
|
139
127
|
>>> f = tf.matmul(X ,W)+b
|
140
128
|
|
141
129
|
Traceback (most recent call last):
|
142
130
|
|
131
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 671, in _call_cpp_shape_fn_impl
|
132
|
+
|
133
|
+
input_tensors_as_shapes, status)
|
134
|
+
|
135
|
+
File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__
|
136
|
+
|
137
|
+
next(self.gen)
|
138
|
+
|
139
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
|
140
|
+
|
141
|
+
pywrap_tensorflow.TF_GetCode(status))
|
142
|
+
|
143
|
+
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 0 and 2 for 'MatMul_1' (op: 'MatMul') with input shapes: [?,0], [2,5].
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
During handling of the above exception, another exception occurred:
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
Traceback (most recent call last):
|
152
|
+
|
143
153
|
File "<stdin>", line 1, in <module>
|
144
154
|
|
155
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/ops/math_ops.py", line 1816, in matmul
|
156
|
+
|
157
|
+
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
|
158
|
+
|
159
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1217, in _mat_mul
|
160
|
+
|
161
|
+
transpose_b=transpose_b, name=name)
|
162
|
+
|
163
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
|
164
|
+
|
165
|
+
op_def=op_def)
|
166
|
+
|
167
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2508, in create_op
|
168
|
+
|
169
|
+
set_shapes_for_outputs(ret)
|
170
|
+
|
171
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1873, in set_shapes_for_outputs
|
172
|
+
|
173
|
+
shapes = shape_func(op)
|
174
|
+
|
175
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1823, in call_with_requiring
|
176
|
+
|
177
|
+
return call_cpp_shape_fn(op, require_shape_fn=True)
|
178
|
+
|
179
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
|
180
|
+
|
145
|
-
|
181
|
+
debug_python_shape_fn, require_shape_fn)
|
182
|
+
|
183
|
+
File "/home/daisuke/.local/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl
|
184
|
+
|
185
|
+
raise ValueError(err.message)
|
186
|
+
|
187
|
+
ValueError: Dimensions must be equal, but are 0 and 2 for 'MatMul_1' (op: 'MatMul') with input shapes: [?,0], [2,5].
|
188
|
+
|
189
|
+
>>>
|
190
|
+
|
191
|
+
|
146
192
|
|
147
193
|
|
148
194
|
|
149
195
|
```
|
150
196
|
|
151
|
-
と
|
197
|
+
とより複雑なエラーが出てきました・・・
|
1
エラーなどの全文を追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -83,3 +83,69 @@
|
|
83
83
|
python3.x
|
84
84
|
|
85
85
|
tensorflow 0.7.1
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
####追記
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
再度動かしたところ、
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
>>> import tensorflow as tf
|
102
|
+
|
103
|
+
>>>
|
104
|
+
|
105
|
+
>>> def weight(shape = []):
|
106
|
+
|
107
|
+
... initial = tf.truncated_nomal(shape, stddev = 0.01)
|
108
|
+
|
109
|
+
... return tf.Variable(initial)
|
110
|
+
|
111
|
+
...
|
112
|
+
|
113
|
+
>>> def bias(dtype =tf.float32, shape = []):
|
114
|
+
|
115
|
+
... initial = tf.zeros(shape, dtype= dtype)
|
116
|
+
|
117
|
+
... return tf.Variable(initial)
|
118
|
+
|
119
|
+
...
|
120
|
+
|
121
|
+
>>> P,Q=5,2
|
122
|
+
|
123
|
+
>>>
|
124
|
+
|
125
|
+
>>> X = tf.placeholder(dtype = tf.float32, shape =[None, 0])
|
126
|
+
|
127
|
+
>>> W = weight(shape = [Q,P])
|
128
|
+
|
129
|
+
Traceback (most recent call last):
|
130
|
+
|
131
|
+
File "<stdin>", line 1, in <module>
|
132
|
+
|
133
|
+
File "<stdin>", line 2, in weight
|
134
|
+
|
135
|
+
AttributeError: module 'tensorflow' has no attribute 'truncated_nomal'
|
136
|
+
|
137
|
+
>>> b = bias(shape = [P])
|
138
|
+
|
139
|
+
>>> f = tf.matmul(X ,W)+b
|
140
|
+
|
141
|
+
Traceback (most recent call last):
|
142
|
+
|
143
|
+
File "<stdin>", line 1, in <module>
|
144
|
+
|
145
|
+
NameError: name 'W' is not defined
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
と違うエラーが出てきてしまいました。
|