Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lasso tests on GPU #463

Merged
merged 4 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# v0.2.2

This version adds support for PyTorch 1.4.0. There are also several minor feature improvements and bug fixes listed below.

- added option for neutral elements to be used in the place of empty tensors in reduction operations (`operations.__reduce_op`) (cf. [#369](https://github.com/helmholtz-analytics/heat/issues/369) and [#444](https://github.com/helmholtz-analytics/heat/issues/444))
- `var` and `std` both now support iterable axis arguments
- updated pull request template
- bug fix: `x.unique()` returns a DNDarray both in distributed and non-distributed mode (cf. [#464])
- [#443](https://github.com/helmholtz-analytics/heat/pull/443) added option for neutral elements to be used in the place of empty tensors in reduction operations (`operations.__reduce_op`) (cf. [#369](https://github.com/helmholtz-analytics/heat/issues/369) and [#444](https://github.com/helmholtz-analytics/heat/issues/444))
- [#445](https://github.com/helmholtz-analytics/heat/pull/445) `var` and `std` both now support iterable axis arguments
- [#452](https://github.com/helmholtz-analytics/heat/pull/452) updated pull request template
- [#465](https://github.com/helmholtz-analytics/heat/pull/465) bug fix: `x.unique()` returns a DNDarray both in distributed and non-distributed mode (cf. [#464])
- [#463](https://github.com/helmholtz-analytics/heat/pull/463) Bugfix: Lasso tests now run with both GPUs and CPUs

# v0.2.1

Expand Down
32 changes: 22 additions & 10 deletions heat/core/regression/lasso/tests/test_lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ def test_lasso(self):
# ToDo: add additional tests
# get some test data
X = ht.load_hdf5(
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"), dataset="x"
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"),
dataset="x",
device=ht_device,
)
y = ht.load_hdf5(
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"), dataset="y"
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"),
dataset="y",
device=ht_device,
)

# normalize dataset
Expand Down Expand Up @@ -60,15 +64,19 @@ def test_lasso(self):
self.assertEqual(yest.shape, (m,))

X = ht.load_hdf5(
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"), dataset="x"
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"),
dataset="x",
device=ht_device,
)
y = ht.load_hdf5(
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"), dataset="y"
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"),
dataset="y",
device=ht_device,
)

# Now the same stuff again in PyTorch
X = torch.tensor(X._DNDarray__array)
y = torch.tensor(y._DNDarray__array)
X = torch.tensor(X._DNDarray__array, device=device)
y = torch.tensor(y._DNDarray__array, device=device)

# normalize dataset
X = X / torch.sqrt((torch.mean(X ** 2, 0)))
Expand Down Expand Up @@ -100,15 +108,19 @@ def test_lasso(self):
self.assertEqual(yest.shape, (m,))

X = ht.load_hdf5(
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"), dataset="x"
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"),
dataset="x",
device=ht_device,
)
y = ht.load_hdf5(
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"), dataset="y"
os.path.join(os.getcwd(), "heat/datasets/data/diabetes.h5"),
dataset="y",
device=ht_device,
)

# Now the same stuff again in PyTorch
X = X._DNDarray__array.numpy()
y = y._DNDarray__array.numpy()
X = X._DNDarray__array.cpu().numpy()
y = y._DNDarray__array.cpu().numpy()

# normalize dataset
X = X / np.sqrt((np.mean(X ** 2, axis=0, keepdims=True)))
Expand Down