【发布时间】:2018-05-29 02:46:54
【问题描述】:
我正在尝试根据一组声音样本进行训练。我想通过对正样本进行归一化来使负样本更广泛。
这是我的代码:
for sound in dogbarks:
expandedsound = audio_to_metadata(sound)
preprocessed_dogbarks.append(expandedsound)
for sound in noisesounds:
expandedsound = audio_to_metadata(sound)
preprocessed_noisesounds.append(expandedsound)
labels = [0]*len(preprocessed_noisesounds) +
[1]*len(preprocessed_dogbarks)
assert len(labels) == len(preprocessed_noisesounds) +
len(preprocessed_dogbarks)
allsounds = preprocessed_noisesounds + preprocessed_dogbarks
allsounds_normalized = normalize(allsounds)
当代码尝试规范化数组集并且在我的案例 48 中达到一定数量的成员时,它返回错误:
~/.local/lib/python3.5/site-packages/sklearn/utils/validation.py in
check_array(array, accept_sparse, dtype, order, copy,
force_all_finite, ensure_2d, allow_nd, ensure_min_samples,
ensure_min_features, warn_on_dtype, estimator)
431 force_all_finite)
432 else:
--> 433 array = np.array(array, dtype=dtype, order=order, copy=copy)
434
435 if ensure_2d:
ValueError: setting an array element with a sequence.
但是,如果我只运行 48 号会员,它就可以正常工作。谁能给我一个线索?如果您愿意,我可以提供数据。
谢谢。
【问题讨论】:
-
请提供一些有关您正在尝试做什么的上下文并提供代码。
-
更新了@pault。如果您需要更多信息,请告诉我。谢谢
-
你在使用sklean.preprocessing.normalize吗?
allsounds的类型和维度是什么? -
是的,我使用 sklean.preprocessing.normalize,
allsounds的维度是 2,它们是浮点数。 -
你有什么见解@pault 吗?谢谢
标签: python machine-learning scipy