Commit 792c6a21 authored by Shreyan Chowdhury's avatar Shreyan Chowdhury

resolve merge conflict

parent 83981c32
......@@ -71,36 +71,17 @@ class CRNN(BasePtlModel):
# classifier
x = x.view(-1, x.size(0), 32)
<<<<<<< Updated upstream
=======
# print(x.shape)
>>>>>>> Stashed changes
return x
def rnn_forward(x):
<<<<<<< Updated upstream
=======
# print(x.squeeze().shape)
x = x.squeeze()
>>>>>>> Stashed changes
x = self.gru1(x)[1][1] # TODO: Check if this is correct
x = self.dropout(x)
logit = nn.Sigmoid()(self.dense(x))
return logit
def extract_features(song_idx, song_length):
<<<<<<< Updated upstream
song_feats = []
for l in range(song_length//self.input_size + 1):
data = h5data[song_idx + l*self.input_size:song_idx + min(song_length, (l + 1) * self.input_size)].transpose()
data = np.pad(data, ((0, 0), (0, self.input_size-data.shape[1])), mode='wrap')
try:
song_feats.append(cnn_forward(torch.tensor([[data]], device=torch.device('cuda'))))
except:
song_feats.append(cnn_forward(torch.tensor([[data]], device=torch.device('cpu'))))
=======
# print(song_idx, song_length)
song_length = 2560
song_feats = []
......@@ -116,7 +97,6 @@ class CRNN(BasePtlModel):
song_feats.append(cnn_forward(torch.tensor([[data]], device=torch.device('cpu'))))
# print("song feats", song_feats.__len__(), song_feats[0].shape)
>>>>>>> Stashed changes
return torch.cat(song_feats)
h5data, idx_list, x_lengths_list, labels_list = batch
......@@ -124,12 +104,9 @@ class CRNN(BasePtlModel):
for n, ind in enumerate(idx_list):
sequences.append(extract_features(ind, x_lengths_list[n]))
<<<<<<< Updated upstream
sequences_padded = torch.nn.utils.rnn.pad_sequence(sequences, batch_first=True)
=======
# print("sequences", sequences.__len__(), sequences[0].shape)
sequences_padded = torch.nn.utils.rnn.pad_sequence(sequences, batch_first=False)
>>>>>>> Stashed changes
result = rnn_forward(sequences_padded)
return result
......@@ -214,17 +191,9 @@ class CRNN(BasePtlModel):
parser.add_argument('--gru_num_layers', default=2, type=int)
parser.opt_list('--drop_prob', default=0.2, options=[0.2, 0.5], type=float, tunable=False)
parser.opt_list('--learning_rate', default=0.0001, type=float,
options=[0.00001, 0.0005, 0.001],
<<<<<<< Updated upstream
tunable=True)
parser.opt_list('--slicing_mode', default='full', options=['full', 'slice'], type=str, tunable=False)
parser.opt_list('--input_size', default=512, options=[512, 1024], type=int, tunable=True)
=======
tunable=False)
options=[0.00001, 0.0005, 0.001], tunable=False)
parser.opt_list('--slicing_mode', default='full', options=['full', 'slice'], type=str, tunable=True)
parser.opt_list('--input_size', default=512, options=[512, 1024], type=int, tunable=False)
>>>>>>> Stashed changes
# training params (opt)
parser.opt_list('--optimizer_name', default='adam', type=str,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment