【发布时间】:2016-10-26 06:40:35
【问题描述】:
在 Tensorflow 中,我想创建一个除单个元素外的所有掩码,其中元素位置是随机选择的。具体来说,我想创建一个 [0,1,1,1] 或 [1,1,0,1] 的随机掩码
我试过了:
import tensorflow as tf
import numpy as np
# randomly draw the column to select (either column 0 or 2)
COLselect = tf.to_int64(tf.greater(tf.random_uniform((1,)), 0.5))
column_num = COLselect*2
ones_mask = tf.Variable(numpy.ones((4,)))
我一直在纠结如何创建一个新的掩码,将 one_mask 的 column_num 列清空。
我尝试关注Manipulating matrix elements in tensorflow,但失败了,因为该列是张量。
谢谢
【问题讨论】:
标签: tensorflow