Skip to content

Commit

Permalink
Update torch nightly and pin torchvision to fix CI (#2072)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgaddair committed May 28, 2022
1 parent 8e1b329 commit 59b2d1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ jobs:
if [ $PYTORCH == "nightly" ]; then
cat requirements.txt | sed '/^torch[>=<]/d' > requirements-temp && mv requirements-temp requirements.txt
extra_index_url=https://download.pytorch.org/whl/nightly/cpu
# TODO: temp fix for https://github.com/pytorch/vision/issues/5873
pip install --pre torch==1.12.0.dev20220421+cpu torchtext torchvision torchaudio --extra-index-url $extra_index_url
pip install --pre torch==1.13.0.dev20220527+cpu torchtext torchaudio --extra-index-url $extra_index_url
# TODO: temp fix for https://github.com/pytorch/vision/issues/6103
pip install https://download.pytorch.org/whl/nightly/cpu/torchvision-0.14.0.dev20220527%2Bcpu-cp39-cp39-linux_x86_64.whl
else
extra_index_url=https://download.pytorch.org/whl/cpu
pip install torch==$PYTORCH torchtext torchvision torchaudio --extra-index-url $extra_index_url
Expand Down
2 changes: 1 addition & 1 deletion ludwig/data/batcher/bucketed.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def set_epoch(self, epoch, batch_size):
self.steps_per_epoch = self._compute_steps_per_epoch()

def _compute_steps_per_epoch(self) -> int:
return int(np.asscalar(np.sum(np.ceil(self.bucket_sizes / self.batch_size))))
return int(np.sum(np.ceil(self.bucket_sizes / self.batch_size)).item())


# dynamic_length_encoders = {
Expand Down
6 changes: 3 additions & 3 deletions ludwig/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,13 +1456,13 @@ def compare_classifiers_performance_from_prob(
hits_at_k = 0
for j in range(len(ground_truth)):
hits_at_k += np.in1d(ground_truth[j], topk[j])
hits_at_ks.append(np.asscalar(hits_at_k) / len(ground_truth))
hits_at_ks.append(hits_at_k.item() / len(ground_truth))

mrr = 0
for j in range(len(ground_truth)):
ground_truth_pos_in_probs = prob[j] == ground_truth[j]
if np.any(ground_truth_pos_in_probs):
mrr += 1 / -(np.asscalar(np.argwhere(ground_truth_pos_in_probs)) - prob.shape[1])
mrr += 1 / -(np.argwhere(ground_truth_pos_in_probs).item() - prob.shape[1])
mrrs.append(mrr / len(ground_truth))

filename = None
Expand Down Expand Up @@ -1663,7 +1663,7 @@ def compare_classifiers_performance_subset(
hits_at_k = 0
for j in range(len(gt_subset)):
hits_at_k += np.in1d(gt_subset[j], top3_subset[i, :])
hits_at_ks.append(np.asscalar(hits_at_k) / len(gt_subset))
hits_at_ks.append(hits_at_k.item() / len(gt_subset))

title = None
if subset == "ground_truth":
Expand Down

0 comments on commit 59b2d1b

Please sign in to comment.