Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit 9389a58

Browse files
committedMar 19, 2020
perf(svm): 转换torch到numpy之前先从cuda转换到cpu
1 parent f03f1ef commit 9389a58

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎py/linear_svm.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def train_model(data_loaders, model, criterion, optimizer, lr_scheduler, num_epo
200200
# print(outputs.shape)
201201
_, preds = torch.max(outputs, 1)
202202

203-
hard_negative_list, easy_neagtive_list = add_hard_negatives(preds.numpy(), cache_dicts)
203+
hard_negative_list, easy_neagtive_list = add_hard_negatives(preds.cpu().numpy(), cache_dicts)
204204

205205
negative_list.extend(hard_negative_list)
206206
res_negative_list.extend(easy_neagtive_list)
@@ -230,8 +230,8 @@ def train_model(data_loaders, model, criterion, optimizer, lr_scheduler, num_epo
230230

231231

232232
if __name__ == '__main__':
233-
# device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
234-
device = 'cpu'
233+
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
234+
# device = 'cpu'
235235

236236
data_loaders, data_sizes = load_data('./data/classifier_car')
237237

0 commit comments

Comments
 (0)
Failed to load comments.