我想以這樣一種方式轉換這個數據集,即每個張量都有給定的大小,n并且i當且僅當i原始特征(模 n)中有一個時,這個新張量的索引處的特征設置為 1 。我希望下面的例子能讓事情更清楚假設我有一個數據集,如:t = tf.constant([ [0, 3, 4], [12, 2 ,4]])ds = tf.data.Dataset.from_tensors(t)我想得到(如果n= 9)t = tf.constant([ [1, 0, 0, 1, 1, 0, 0, 0, 0], # index set to 1 are 0, 3 and 4 [0, 0, 1, 1, 1, 0, 0, 0, 0]]) # index set to 1 are 2, 4, and 12%9 = 3我知道如何將模應用于張量,但我不知道如何進行其余的轉換,謝謝
添加回答
舉報
0/150
提交
取消