質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 2.7

Python 2.7は2.xシリーズでは最後のメジャーバージョンです。Python3.1にある機能の多くが含まれています。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

5220閲覧

tensorflow1.0でmulの代替関数

tak__tak

総合スコア78

Python 2.7

Python 2.7は2.xシリーズでは最後のメジャーバージョンです。Python3.1にある機能の多くが含まれています。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2017/04/06 10:05

tensorflow1.0では mul は使えないのですが
代わりとなる関数は matmul で完全に問題ないでしょうか?

何かtensorflow0.x のmul との違いは無いでしょうか?

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答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
can110

総合スコア38266

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問