這裏看到:https://gist.github.com/narphorium/d06b7ed234287e319f18爲什麼增加張量的維數可以實現元素減法?
這是重現,能夠代碼:
import numpy as np
import tensorflow as tf
points = np.random.random_sample((10,2))
tf_points = tf.constant(points)
slice = tf.slice(tf_points,[0,0],[4,-1])
print tf.subtract(tf_points,slice).get_shape() #This errors out because the dimensions are incorrect
tf_points_expanded = tf.expand_dims(tf_points,0)
slice_expanded = tf.expand_dims(slice,1)
print tf.subtract(tf_points_expanded,slice_expanded).get_shape() #This works and prints (4,10,2)
這是爲什麼元素方面的減法?這個怎麼用?