ファイルから翻訳済みの行列を作成しようとしています。ファイルには、次のようになりますし、発症を表し、ピアノのための時間が、私はこの私を行うには、このようなnumpy maxtixを構築する
Event State
time Piano state, array of length 88
...
のようなピアノの状態表現とイベントの時間にこれを平らにしようとしています
OnsetTime OffsetTime MidiPitch
0.500004 0.85356 37
1.20712 1.50441 38
1.80171 2.0517 39
...
ノートオフセットフォローコード
eventArray = np.array([])
with open('event_log.txt') as tsv:
noteState = [0] * 88
iterator = iter(csv.reader(tsv, dialect="excel-tab"))
next(iterator)
for line in iterator:
notePosition = int(float(line[2])) - 21
noteState[notePosition] = 1
np.concatenate(eventArray, np.array([float(line[0]), noteState]))
noteState[notePosition] = 0
np.concatenate(eventArray, np.array([float(line[1]), noteState]))
を構築しかし、私はこれを実行すると、私は次のようなエラー
を取得していますFile "main.py", line 32, in <module>
np.concatenate(eventArray, np.array([float(line[0]), noteState]))
ValueError: setting an array element with a sequence.
この行列をどのように構築する必要がありますか?私はnumpyを使用して、必要に応じて行列をスライスして整形し直します。
EDIT
コメントで提案を試みた後、私は今
np.concatenate(eventArray, np.array([[float(line[0])], noteState]))
を持っており、
Traceback (most recent call last):
File "main.py", line 32, in <module>
np.concatenate(eventArray, np.array([[float(line[0])], noteState]))
TypeError: only integer scalar arrays can be converted to a scalar index
これは微妙ですが、新しいエラーが発生しました。 'TypeError:整数スカラー配列のみスカラーインデックスに変換できます。' – JME
私はそれが間違っていたと思います – GWW