(dataset)
| 71 | |
| 72 | |
| 73 | def get_data(dataset): |
| 74 | x_train = torch.from_numpy(dataset.x_train).to(torch.float32) # (time_series_num, series_len, sensors_num) |
| 75 | x_test = torch.from_numpy(dataset.x_test).to(torch.float32) |
| 76 | |
| 77 | if dataset.y_train.ndim > 1: |
| 78 | y_train = torch.from_numpy(dataset.y_train.argmax(axis=1)).to(torch.long) # 10分类 |
| 79 | y_test = torch.from_numpy(dataset.y_test.argmax(axis=1)).to(torch.long) |
| 80 | else: |
| 81 | y_train = torch.from_numpy(dataset.y_train).to(torch.long) |
| 82 | y_test = torch.from_numpy(dataset.y_test).to(torch.long) |
| 83 | |
| 84 | time_dim_train = torch.arange(x_train.size(1)).reshape(1, -1, 1).expand(x_train.size(0), -1, 1).to(torch.float32) |
| 85 | time_dim_test = torch.arange(x_test.size(1)).reshape(1, -1, 1).expand(x_test.size(0), -1, 1).to(torch.float32) |
| 86 | assert (time_dim_train.size(1) == time_dim_test.size(1)) |
| 87 | |
| 88 | # x_train = torch.cat((time_dim_train, x_train), 2) |
| 89 | # x_test = torch.cat((time_dim_test, x_test), 2) |
| 90 | time_stamp = time_dim_train[0].squeeze(-1) |
| 91 | |
| 92 | return x_train, y_train, x_test, y_test, time_stamp |
| 93 | |
| 94 | |
| 95 | def get_data_mat(data_path, input_scaling=1): |
nothing calls this directly
no outgoing calls
no test coverage detected