[英]python normalize weird behaviour
我正在嘗試根據一組聲音樣本進行培訓。 我想通過對正樣本進行歸一化來擴大負樣本的范圍。
這是我的代碼:
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,則效果很好。 誰能給我一個線索? 如果您願意,我可以提供數據。
謝謝。
由於沒有簡單的解決方案可以解決我的問題。 我正在采用另一種方法,它逐一循環並對其進行規范化,然后將其放回數組。
for sound in allsounds :
allsounds_normalized.append(normalize([sound])[0])
讓我知道你們是否有更好的解決方案,但是現在,這是解決方案。 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.