【发布时间】:2019-04-19 18:29:51
【问题描述】:
我正在尝试使用 VGGish 模型的预训练基础生成的 128 字节嵌入来对音频数据进行迁移学习。使用python vggish_inference_demo.py --wav_file ... 将我的训练数据编码为 tfrecord 效果很好,但现在我想将其用作另一个模型的输入(例如,我用 keras 或其他东西创建的神经网络)。使用一些similar questions 和文档,我用一个文件的第一个嵌入记录走了这么远:
tfrecords_filename = 'example1.tfrecord'
record_iterator = tf.python_io.tf_record_iterator(path=tfrecords_filename)
string_record = next(record_iterator)
example = tf.train.SequenceExample()
example.ParseFromString(string_record)
print(example.feature_lists.feature_list['audio_embedding'].feature[0].bytes_list.value)
这会产生
[b'\x99\x07\xaa>\xd2_R_\x9f\xbbqN\x99\xa18V\xad\x7f\x93\xf0)\xdd4\x80~\xb0\xa4d\x8e\x85\xb6\x88\xa3?U\xa6Q[\x9b\x038\xff\x00EE>OJ\xa5\xb8\x828)\x97^\x8a\xaa\x12h\xff\xff\xc39\xce\x9b\x13\x80\x00j\xcaZ\xac\xff\xff\x0f\xac\x1c\x90&\xd2.b\xe2{\xc1\x15\xe9\xba\xed\xd4\xa9\xff\xdc\xb5\x99]!\x04\xca\xff\xa6;b\xe0\x19\xbfW\xebP!\xff\xc5\xff\x82\xff\x1a\xbe\xec-h\xff\x8d\xff\r\x96\x00\x00\xff']
我什至不确定这个 b'...' 是什么(超过 64 个,不到 128 个 xs - 所以不确定它与任何东西的关系)。
也许我在这里缺少一些基本的 Python 知识,但是如何将其转换为可以用作其他模型的输入的数字数组?
【问题讨论】:
标签: python-3.x tensorflow embedding tfrecord transfer-learning