[Bug] TypeError while training
Description
Step to reproduce
- Installed using
pip - Run as
spleeter train -p "D:\_rock_samples\data\ac dc\acdc.json" -d "D:\_rock_samples\data\ac dc" --verbose - Got
TypeError: Value passed to parameter 'x' has DataType uint8 not in list of allowed values: bfloat16, float16, float32, float64, int32, int64error
Output
D:\_rock_samples\data\ac dc>spleeter train -p "D:\_rock_samples\data\ac dc\acdc.json" -d "D:\_rock_samples\data\ac dc" --verbose
WARNING: Logging before flag parsing goes to stderr.
I1118 01:24:07.113108 10540 estimator.py:209] Using config: {'_model_dir': 'D:/_rock_samples/data/ac dc/model/', '_tf_random_seed': 3, '_save_summary_steps': 5, '_save_checkpoints_steps': 300, '_save_checkpoints_secs': None, '_session_config': gpu_options {
per_process_gpu_memory_fraction: 0.45
}
, '_keep_checkpoint_max': 2, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 10, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x0000023BA664BDD8>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
INFO:spleeter:Start model training
I1118 01:24:07.113108 10540 train.py:93] Start model training
I1118 01:24:07.114109 10540 estimator_training.py:186] Not using Distribute Coordinator.
I1118 01:24:07.114109 10540 training.py:612] Running training and evaluation locally (non-distributed).
I1118 01:24:07.115110 10540 training.py:700] Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps 300 or save_checkpoints_secs None.
W1118 01:24:07.120115 10540 deprecation.py:323] From c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\training\training_util.py:236: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
W1118 01:24:07.154145 10540 deprecation.py:323] From c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\data\util\random_seed.py:58: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
W1118 01:24:07.159150 10540 deprecation_wrapper.py:119] From c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\dataset.py:251: The name tf.string_join is deprecated. Please use tf.strings.join instead.
Traceback (most recent call last):
File "c:\users\pawel\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Pawel\AppData\Local\Programs\Python\Python37\Scripts\spleeter.exe\__main__.py", line 9, in <module>
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\__main__.py", line 47, in entrypoint
main(sys.argv)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\__main__.py", line 41, in main
entrypoint(arguments, params)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\commands\train.py", line 97, in entrypoint
evaluation_spec)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 473, in train_and_evaluate
return executor.run()
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 613, in run
return self.run_local()
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow_estimator\python\estimator\training.py", line 714, in run_local
saving_listeners=saving_listeners)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 367, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1158, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1185, in _train_model_default
input_fn, ModeKeys.TRAIN))
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1022, in _get_features_and_labels_from_input_fn
self._call_input_fn(input_fn, mode))
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 1113, in _call_input_fn
return input_fn(**kwargs)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\dataset.py", line 86, in get_training_dataset
wait_for_cache=False)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\dataset.py", line 413, in build
dataset = dataset.map(instrument.convert_to_uint)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1772, in map
MapDataset(self, map_func, preserve_cardinality=False))
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 3190, in __init__
use_legacy_function=use_legacy_function)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 2555, in __init__
self._function = wrapper_fn._get_concrete_function_internal()
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\eager\function.py", line 1355, in _get_concrete_function_internal
*args, **kwargs)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\eager\function.py", line 1349, in _get_concrete_function_internal_garbage_collected
graph_function, _, _ = self._maybe_define_function(args, kwargs)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\eager\function.py", line 1652, in _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\eager\function.py", line 1545, in _create_graph_function
capture_by_value=self._capture_by_value),
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\framework\func_graph.py", line 715, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 2549, in wrapper_fn
ret = _wrapper_helper(*args)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 2489, in _wrapper_helper
ret = func(*nested_args)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\dataset.py", line 162, in convert_to_uint
max_key=self._max_spectrogram_key))
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\utils\audio\convertor.py", line 73, in spectrogram_to_db_uint
db_spectrogram = gain_to_db(spectrogram)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\spleeter\utils\audio\convertor.py", line 54, in gain_to_db
return 20. / np.log(10) * tf.math.log(tf.maximum(tensor, espilon))
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 6468, in maximum
"Maximum", x=x, y=y, name=name)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 626, in _apply_op_helper
param_name=input_name)
File "c:\users\pawel\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 60, in _SatisfiesTypeConstraint
", ".join(dtypes.as_dtype(x).name for x in allowed_list)))
TypeError: Value passed to parameter 'x' has DataType uint8 not in list of allowed values: bfloat16, float16, float32, float64, int32, int64
D:\_rock_samples\data\ac dc>
Environment
| OS | Windows 10 1903 |
| Installation type | PIP |
| RAM available | 16 GB |
| Hardware spec | Ryzen 5 2600. RTX 2070 8GB |
Additional context
I've created small dataset along with .csv files and this happened when tried to train it for the first time. Dataset contains wav/flac files and validation set contains wav/ogg files.
Having a similar issue with wav files. @xpawelsky did you find the solution? To me it looks like a problem with the audio files or the tf version.
INFO:tensorflow:Using config: {'_model_dir': 'noise', '_tf_random_seed': 3, '_save_summary_steps': 5, '_save_checkpoints_steps': 1000, '_save_checkpoints_secs': None, '_session_config': gpu_options {
per_process_gpu_memory_fraction: 0.45
}
, '_keep_checkpoint_max': 2, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 10, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x1c4336da90>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
INFO:spleeter:Start model training
INFO:tensorflow:Not using Distribute Coordinator.
INFO:tensorflow:Running training and evaluation locally (non-distributed).
INFO:tensorflow:Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps 1000 or save_checkpoints_secs None.
WARNING:tensorflow:From /anaconda3/lib/python3.7/site-packages/tensorflow/python/training/training_util.py:236: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
Traceback (most recent call last):
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 527, in _apply_op_helper
preferred_dtype=default_dtype)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1224, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1018, in _TensorTensorConversionFunction
(dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype int64 for Tensor with dtype float32: 'Tensor("sub/y:0", shape=(), dtype=float32)'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/anaconda3/bin/spleeter", line 8, in <module>
sys.exit(entrypoint())
File "/anaconda3/lib/python3.7/site-packages/spleeter/__main__.py", line 54, in entrypoint
main(sys.argv)
File "/anaconda3/lib/python3.7/site-packages/spleeter/__main__.py", line 46, in main
entrypoint(arguments, params)
File "/anaconda3/lib/python3.7/site-packages/spleeter/commands/train.py", line 98, in entrypoint
evaluation_spec)
File "/anaconda3/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 473, in train_and_evaluate
return executor.run()
File "/anaconda3/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 613, in run
return self.run_local()
File "/anaconda3/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 714, in run_local
saving_listeners=saving_listeners)
File "/anaconda3/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 367, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/anaconda3/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1158, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/anaconda3/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1185, in _train_model_default
input_fn, ModeKeys.TRAIN))
File "/anaconda3/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1022, in _get_features_and_labels_from_input_fn
self._call_input_fn(input_fn, mode))
File "/anaconda3/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1113, in _call_input_fn
return input_fn(**kwargs)
File "/anaconda3/lib/python3.7/site-packages/spleeter/dataset.py", line 78, in get_training_dataset
wait_for_cache=False)
File "/anaconda3/lib/python3.7/site-packages/spleeter/dataset.py", line 381, in build
dataset = self.compute_segments(dataset, n_chunks_per_song)
File "/anaconda3/lib/python3.7/site-packages/spleeter/dataset.py", line 320, in compute_segments
dataset.map(lambda sample: dict(sample, start=tf.maximum(
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1772, in map
MapDataset(self, map_func, preserve_cardinality=False))
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 3190, in __init__
use_legacy_function=use_legacy_function)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2555, in __init__
self._function = wrapper_fn._get_concrete_function_internal()
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1355, in _get_concrete_function_internal
*args, **kwargs)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1349, in _get_concrete_function_internal_garbage_collected
graph_function, _, _ = self._maybe_define_function(args, kwargs)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1652, in _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1545, in _create_graph_function
capture_by_value=self._capture_by_value),
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py", line 715, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2549, in wrapper_fn
ret = _wrapper_helper(*args)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2489, in _wrapper_helper
ret = func(*nested_args)
File "/anaconda3/lib/python3.7/site-packages/spleeter/dataset.py", line 323, in <lambda>
* self.MARGIN) / (n_chunks_per_song - 1)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py", line 897, in binary_op_wrapper
return func(x, y, name=name)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 10855, in sub
"Sub", x=x, y=y, name=name)
File "/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 563, in _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Sub' Op has type float32 that does not match type int64 of argument 'x'.
I managed to find the issue. My wav files where
$ file track.wav
RIFF (little-endian) data, WAVE audio, stereo 44100 Hz
and they have to be:
RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz
I converted easily using ffmpeg:
ffmpeg -i input.wav -acodec pcm_s16le -ac 2 -ar 44100 output.wav
@mmoussallam 我也碰到了这个问题,但是我按照你的步骤去做了之后并没有奏效,请问还有其他办法吗