我说的是 https://research.google.com/audioset/download.html 上提供的音频特征数据集作为由帧级音频 tfrecord 组成的 tar.gz 存档。
从 tfrecord 文件中提取其他所有内容都可以正常工作(我可以提取键:video_id、start_time_seconds、end_time_seconds、标签),但训练所需的实际嵌入似乎根本不存在。当我迭代数据集中任何 tfrecord 文件的内容时,仅打印四个键 video_id、start_time_seconds、end_time_seconds 和 labels。这是我正在使用的代码:
import tensorflow as tf
import numpy as np
def readTfRecordSamples(tfrecords_filename):
record_iterator = tf.python_io.tf_record_iterator(path=tfrecords_filename)
for string_record in record_iterator:
example = tf.train.Example()
example.ParseFromString(string_record)
print(example) # this prints the abovementioned 4 keys but NOT audio_embeddings
# the first label can be then parsed like this:
label = (example.features.feature['labels'].int64_list.value[0])
print('label 1: ' + str(label))
# this, however, does not work:
#audio_embedding = (example.features.feature['audio_embedding'].bytes_list.value[0])
readTfRecordSamples('embeddings/01.tfrecord')
提取 128 维嵌入有什么技巧吗? 或者它们真的不在这个数据集中吗?
最佳答案
解决了,tfrecord 文件需要作为序列示例而不是示例来读取。如果行以上代码有效
example = tf.train.Example()
被替换为
example = tf.train.SequenceExample()
只需运行即可查看嵌入和所有其他内容
print(example)
关于python - 如何从 Google 的 AudioSet 中提取音频嵌入(特征)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46204992/