3

As far as I know, Using numpy() method isn't possible in map function in tensorflow dataset. So how can I get the value of a tensor there? I want to convert a tensor to an int there so that I can use it as an index of a dictionary.

def process_path(file_path):
  print('file_path in process_path:', file_path)
  label = tf.strings.split(tf.strings.split(file_path, '/')[-1], '.')[-2]
  print('label in process_path:', label, type(label))
  label = tf.strings.to_number(label, tf.int64)

  labelint = labels['Male'][label]
  print(labelint)
  img = tf.io.read_file(file_path)
  img = decode_img(img)
  return img, label

I want to use above code in the map function, but I get error! I appreciate your help.

  • You can, check my answer [here](https://stackoverflow.com/questions/63062304/extracting-numpy-value-from-tensorflow-object-during-transformation/63064174#63064174) – Luciano Dourado Aug 01 '20 at 15:54

0 Answers0