【发布时间】:2020-02-05 19:19:10
【问题描述】:
我使用的是 TensorFlow 1.15 我有一个张量,其中包含一个形状为 (BatchsizeWidthHeight*3)
的图像我有一个大小为 Batchsize*50*50*3 的补丁 我想在原始图像中指定插入补丁的位置。 但是为了让它更简单,假设我有一个包含 10 个元素的一维数组并且想要 替换给定索引处的单个值 开头应该是这样的。
sess = tf.Session()
array = tf.placeholder("float32",[10]) # for easier explanation a 1d array
variable = tf.get_variable(name=var,shape=[1],intializer=init) # This variable should replace the value
index = tf.placeholder("int32",[1]) # the value on this index should be replaced
# Here The value of the image tensor at place index should be replaced with the variable
in_dict = {image: np.zeros([10],dtype="float")
index: 4}
sess.run(...,feed_dict=in_dict)
tf.where 需要两个大小相同的张量,但我的变量和数组的大小不同。
【问题讨论】:
标签: python tensorflow