How can i change the the tensor value into normal text data?

52 views Asked by At

this is a function that return acoustic feature, inside there is function load_npy_file to get features from the given path

When i tried to call it directly from it function, it work well

but when i try to load dataset into tf.dataset, it dont work because it says that the path im trying to give wasnt a string

`TypeError: in user code:

File "/tmp/ipykernel_2317168/3292140411.py", line 7, in encode_single_sample  *
    acoustic_features = load_npy_file(file_path)
File "/tmp/ipykernel_2317168/3596944538.py", line 2, in load_npy_file  *
    return np.load(file_path)
File "/home/c11190018/ASR/lib/python3.10/site-packages/numpy/lib/npyio.py", line 405, in load  **
    fid = stack.enter_context(open(os_fspath(file), "rb"))

TypeError: expected str, bytes or os.PathLike object, not Tensor`

i know that if we try to map into the tf.dataset, the function called will give the params from the sliced data, and i dont know how to change it into normal string, any suggestions?

1

There are 1 answers

0
TF_Chinmay On

It looks like the function under our consideration here tf.data.Dataset.from_tensor_slices requires a single list as the argument however 3 separate lists were given as per your code snippet, as per the documentation.

Do enter your arguments in one list to solve the problem.

tf.data.Dataset.from_tensor_slices