tf.pow, tf.math.pow解説
6597 ワード
tf.pow, tf.math.powは同じです
この操作は、xとyの対応する要素がx y x^{y}xyを計算し、「ブロードキャスト方式(このブログを書く初心)」をサポートしてtensorを返すことに注意します.
tf.math.pow(
x,
y,
name=None
)
sess=tf.Session()
x=tf.constant([[2,3],[4,5]])
y_1=2
res_1=tf.pow(x,y_1)
sess.run(res_1)
'''
array([[ 4, 9],
[16, 25]], dtype=int32)
'''
x=tf.constant([[2,3],[4,5]])
y_2=[2,3]
sess.run(tf.pow(x,y_2))
'''
:
array([[ 4, 27],
[ 16, 125]], dtype=int32)
'''
x=tf.constant([[2,3],[4,5]])
y_3=[[2],[3]]
sess.run(tf.pow(x,y_3))
'''
:
array([[ 4, 9],
[ 64, 125]], dtype=int32)
'''
x=tf.constant([[2,3],[4,5]])
y_4=[[1,2],[3,2]]
sess.run(tf.pow(x,y_4))
'''
:
array([[ 2, 9],
[64, 25]], dtype=int32)
'''