-1
int32の1次元テンソルがあります。最初に出現する前の要素を0に置き換えたいと思います。1次元テンソルを特定のインデックステンソルで分割する方法は?
#This is a numpy equivalent.
import numpy as np
a = np.array([5, 4, 1, 3, 1, 2, 3, 3, 1, 5], np.int32)
first_ind = np.where(a == 1)[0][0] # => 2
result = np.concatenate((np.zeros((first_ind,)), a[first_ind:]))
# =>[ 0. 0. 1. 3. 1. 2. 3. 3. 1. 5.]
import tensorflow as tf
_a = tf.convert_to_tensor(a)
_first_ind = tf.where(tf.equal(_a, 1))[0][0]
# But I don't know what to do next.