Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def process(self, nparray, length):
tensor = rai.BlobTensor.from_numpy(nparray)
self.con.tensorset('sentence', tensor)
length_tensor = rai.BlobTensor.from_numpy(length)
self.con.tensorset('length', length_tensor)
self.con.modelrun('encoder', input=['sentence', 'length'], output=['e_output', 'd_hidden'])
sos_tensor = rai.BlobTensor.from_numpy(
np.array(utils.SOS_token, dtype=np.int64).reshape(1, 1))
self.con.tensorset('d_input', sos_tensor)
i = 0
out = []
while i < self.max_len:
i += 1
self.con.modelrun(
'decoder',
input=['d_input', 'd_hidden', 'e_output'],
output=['d_output', 'd_hidden'])
d_output = self.con.tensorget('d_output', as_type=rai.BlobTensor).to_numpy()
d_output_ret = d_output.reshape(1, utils.voc.num_words)
ind = int(d_output_ret.argmax())