-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.py
80 lines (53 loc) · 1.75 KB
/
testing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Impor modules for training
import torch
import model as m
import multi_training
from midi_to_statematrix import *
import numpy as np
def test_time_model():
time_model = m.TimeModel(80, [300, 300])
print(time_model)
data = torch.randn(127, 780, 80)
out = time_model(data)
print(out.shape)
def test_pitch_model():
pitch_model = m.PitchModel(80, [300, 300])
print(pitch_model)
data = torch.randn(127, 780, 80)
out = pitch_model(data)
print(out.shape)
def test_training_model():
pcs = multi_training.loadPieces("Train_data")
data = multi_training.getPieceBatch(pcs)
model = m.BiaxialRNNModel([300, 300], [100, 50])
print(model)
out = model(data, training=True)
print(out.shape)
def test_predict_one_step_model():
pcs = multi_training.loadPieces("Train_data")
data, _ = multi_training.getPieceSegment(pcs)
data = torch.Tensor(data[0])
print(data.shape)
model = m.BiaxialRNNModel([300, 300], [100, 50])
print(model)
out = model(data) # Done in order to print
def test_predict_n_step_model():
pcs = multi_training.loadPieces("Train_data")
data, _ = multi_training.getPieceSegment(pcs)
data = torch.Tensor(data[0])
print(data.shape)
model = m.BiaxialRNNModel([300, 300], [100, 50])
print(model)
out = model(data, 5)
print(out)
print(torch.Tensor(np.array(out)).shape)
def main():
# test_time_model()
# test_pitch_model()
# test_training_model()
# test_predict_one_step_model()
# test_predict_n_step_model()
matrix = midiToNoteStateMatrix("Scale/Scale.mid")
print(np.argmax(matrix[0], axis=0))
if __name__ == '__main__':
main()