tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to DecodeRaw has length 1 that is not a multiple of 4, the size of float
[[node DecodeRaw_1 (defined at /GraphRelated/tf_repos/keras_estimator/aaaa.py:63) ]]
解决方案一:
label = tf.decode_raw(features['label'],tf.uint8)
1
Because you use tf.decode_raw to convert your image to double(tf.float64) type, which’s size is 8 bytes. so the parsed[‘mel_spec_raw’] should be a multiple of 8. You can print the type of parsed[‘mel_spec_raw’], it should be tf.string, which explain why the size of the parsed[‘mel_spec_raw’] is 165750. Your can change your code to:
# mel_spec1d = tf.decode_raw(parsed['mel_spec_raw'], tf.float64)
mel_spec1d = tf.decode_raw(parsed[‘mel_spec_raw’], tf.uint8)
it might work, because of the size of tf.uint8 is only 1. If you want to convert the type into tf.float64, you can convert the type into tf.float using tf.cast
mel_spec1d = tf.cast(mel_spec1d, tf.float64)
Hope this will help you.
Input to DecodeRaw is not a multiple of 8, the size of double
博客内容涉及在使用TensorFlow时遇到的`InvalidArgumentError`,具体错误为输入到`DecodeRaw`的长度不是4的倍数。解决方案是检查`decode_raw`的类型转换,建议将数据类型改为`tf.uint8`,如果需要转换为`tf.float64`,可以先用`tf.cast`进行转换。这个错误通常出现在处理图像或音频数据时,数据预处理不正确导致。
918

被折叠的 条评论
为什么被折叠?



