Here I try to get audio and label from raw_dataset(tfrec)
feature_description = {
'recording_id': tf.io.FixedLenFeature([], tf.string, default_value=''),
'audio_wav': tf.io.FixedLenFeature([], tf.string, default_value=''),
'label_info': tf.io.FixedLenFeature([], tf.string, default_value='')
}
def _parse_function(example_proto):
# Parse the input `tf.train.Example` proto using the dictionary above.
example = tf.io.parse_single_example(example_proto, feature_description)
wav = example['audio_wav']
#here error occurs
label = example['label_info'].numpy()
decoded_audio = decode_audio(wav)
decoded_label = tf.constant(process_label(label))
return decoded_audio,decoded_label
AUTOTUNE = tf.data.experimental.AUTOTUNE
parsed_dataset = raw_dataset.map(_parse_function,AUTOTUNE)
This shows me error 'Tensor' object has no attribute 'numpy'
But when I do this:
label = []
for item in raw_dataset:
label.append(process_label(item['label_info'].numpy()))
it works
How can I solve this issue
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…