2024-04-26 00:26:06 发布
网友
我想这样做:
v = tf.get_variable('v', [N]) p = tf.placeholder(shape=[None]) tmp = [] for element_p in p: tmp.append(element_p - v) ret = tf.stack(tmp, axis=0) # ret.get_shape().as_list() = [None, N]
这在张量流中可能吗?你知道吗
利用广播:
import tensorflow as tf N = ... v = tf.get_variable('v', [N]) p = tf.placeholder(shape=[None]) ret = p[:, tf.newaxis] - v[tf.newaxis, :]
利用广播:
相关问题 更多 >
编程相关推荐