Open HelloWorldLTY opened 5 months ago
Hi, I modified the test codes to this following:
@torch.no_grad()
def predict_test(data, models, n_components_list, d_list, batch_size, device='cuda'):
num_samples = len(data)
for i, n_components in enumerate(n_components_list):
for j, d_model in enumerate(d_list):
combined_outputs = []
label_reducer, scaler, transformer_model = models[f'{n_components},{d_model}']
transformer_model.eval()
for i in range(0, num_samples, batch_size):
batch_unseen_data = data[i:i + batch_size]
transformed_data = transformer_model(batch_unseen_data)
if scaler:
transformed_data = torch.tensor(scaler.inverse_transform(
label_reducer.inverse_transform(transformed_data.cpu().detach().numpy()))).to(device)
print(transformed_data.shape)
combined_outputs.append(transformed_data)
# Stack the combined outputs
combined_outputs = torch.vstack(combined_outputs)
sample_submission = pd.read_csv(
f"./sample_submission.csv")
print(sample_submission)
print(combined_outputs.cpu().detach().numpy().shape)
sample_columns = sample_submission.columns
sample_columns = sample_columns[1:]
submission_df = pd.DataFrame(combined_outputs.cpu().detach().numpy(), columns=sample_columns)
submission_df.insert(0, 'id', range(255))
submission_df.to_csv(f"result_{n_components}_{d_model}.csv", index=False)
Then I will have a matrix with shape 255*18211. Is it correct? Thanks.
Hi, thanks for your great work. After running your training step, I tried to reproduce the prediction process:
However, I received the bugs mentioned above. It seems that the output combined_emb has dim with 31, but the target sample submission has dim 255. Are there anything wrong?
My config file looks like:
Thanks a lot.