Skip to content

fix np to torch in bumpy torch #3

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

Merged
merged 1 commit into from
Sep 5, 2024
Merged
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
6 changes: 3 additions & 3 deletions src/optimize_2d_momentum_bumpy_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def bumpy_function(pos: th.Tensor) -> th.Tensor:
import matplotlib.pyplot as plt
from matplotlib import cm

# TODO: use jax to find the gradient.
# TODO: use torch to find the gradient.

nx, ny = (1001, 1001)
x = th.linspace(-3, 3, nx)
Expand All @@ -57,7 +57,7 @@ def bumpy_function(pos: th.Tensor) -> th.Tensor:
step_total = 100

pos_list = [start_pos]
velocity_vec = np.array((0.0, 0.0))
velocity_vec = th.tensor((0.0, 0.0))
# TODO: Implement gradient descent with momentum.

for pos in pos_list:
Expand All @@ -69,5 +69,5 @@ def bumpy_function(pos: th.Tensor) -> th.Tensor:
np.array(my),
np.array(mz),
pos_list,
"writer_grad_bumpy_plot_jax",
"writer_grad_bumpy_plot_torch",
)
Loading