tensorflow1.0では mul は使えないのですが
代わりとなる関数は matmul で完全に問題ないでしょうか?
何かtensorflow0.x のmul との違いは無いでしょうか?
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答1件
0
ベストアンサー
要素毎の乗算tf.mul
の代替は行列の乗算tf.matmul
ではなくtf.multiply
ではないでしょうか?
tf.multiply(r1.0)
Returns x * y element-wise.
NOTE: tf.multiply supports broadcasting. More about broadcasting here
Args:
x: A Tensor. Must be one of the following types: half, float32, float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128.
y: A Tensor. Must have the same type as x.
name: A name for the operation (optional).
Returns:
A Tensor. Has the same type as x.
tf.mul(v0.12)
Returns x * y element-wise.
NOTE: Mul supports broadcasting. More about broadcasting here
Args:
x: A Tensor. Must be one of the following types: half, float32, float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128.
y: A Tensor. Must have the same type as x.
name: A name for the operation (optional).
Returns:
A Tensor. Has the same type as x.
例
Python
1import tensorflow as tf 2print(tf.__version__) 3a = tf.constant([1, 2, 3, 4], shape=[2, 2]) 4b = tf.constant([5, 6, 7, 8], shape=[2, 2]) 5#mu = tf.mul(a, b) # AttributeError: module 'tensorflow' has no attribute 'mul' 6mt = tf.multiply(a, b) # 要素毎に乗算 7mm = tf.matmul(a, b) # 行列の乗算 8with tf.Session() as sess: 9 print(a.eval()) 10 print(b.eval()) 11 print(mt.eval()) 12 print(mm.eval())
結果
1.0.0 [[1 2] [3 4]] [[5 6] [7 8]] [[ 5 12] [21 32]] [[19 22] [43 50]]
投稿2017/04/06 11:00
編集2017/04/07 04:16総合スコア38266
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。