【问题标题】:How can I extract the audio embeddings (features) from Google’s AudioSet?如何从 Google 的 AudioSet 中提取音频嵌入(特征)?
【发布时间】:2017-09-14 20:17:00
【问题描述】:

我说的是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 和标签。

这是我正在使用的代码:

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 维嵌入有什么技巧吗? 还是他们真的不在这个数据集中?

【问题讨论】:

    标签: python tensorflow protocol-buffers


    【解决方案1】:

    已解决,tfrecord 文件需要作为序列示例读取,而不是作为示例读取。上面的代码工作,如果行

    example = tf.train.Example()
    

    被替换为

    example = tf.train.SequenceExample()
    

    然后只需运行即可查看嵌入和所有其他内容

    print(example)
    

    【讨论】:

    • 谢谢,这很有帮助。您能否说明一下您是如何得到实际数字而不是字节字符串的?
    • 获取数字的方法如下:stackoverflow.com/a/44077992/3635467。我花了很长时间才找到它!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 2021-09-21
    • 2014-02-02
    • 2014-01-10
    • 2011-05-09
    • 2023-03-07
    • 1970-01-01
    相关资源
    最近更新 更多