![](/img/trans.png)
[英]There are two logs in the path in file_path, and I want to read each of them using python
[英]I want to know the file_path in the example of tensorflow
tensorflow 的例子是https://www.tensorflow.org/tutorials/audio/simple_audio
我想知道這個例子中的file_path
如下:
def get_waveform_and_label(file_path):
label = get_label(file_path)
audio_binary = tf.io.read_file(file_path)
waveform = decode_audio(audio_binary)
return waveform, label
'file_path' 在 function 中調用如下:
waveform_ds = files_ds.map(get_waveform_and_label, num_parallel_calls=AUTOTUNE)
我嘗試使用print(file_path)
獲取 file_path 的值,但答案是Tensor("args_0:0", shape=(), dtype=string)
。
這不是 file_path 的確切值。
最后,我不知道waveform_ds = files_ds.map(get_waveform_and_label, num_parallel_calls=AUTOTUNE)
中get_waveform_and_label
的file_path
和輸入參數的值。
我一直陷入同樣的問題,但我想我明白了:
file_path來自file_ds變量,其中file_ds “可能代表一大組元素”,其中每個元素是每個 wav 的“文件路徑”。 文件。
設置train_files變量后,運行以下命令以了解我的意思。
file_ds = tf.data.Dataset.from_tensor_slices(train_files)
for element in dataset:
print(element)
然后當你使用 map function
file_ds.map(get_waveform_and_label)
它將 function get_waveform_and_label
應用於大集合的每個元素,在這種情況下,應用於每個 wav 文件。
參考: https://www.tensorflow.org/api_docs/python/tf/data/Dataset
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.