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

Add transforming adaptation #27

Merged
merged 8 commits into from
Oct 23, 2024
Prev Previous commit
Next Next commit
feat: Do not report invalid gradients for transform adapt
aseyboldt committed Oct 23, 2024
commit bc36d05d3e8d2c44bb13a633eaea1343c3ba50fa
12 changes: 12 additions & 0 deletions src/transform_adapt_strategy.rs
Original file line number Diff line number Diff line change
@@ -114,6 +114,12 @@ impl<M: Math, P: Point<M>> Collector<M, P> for DrawCollector<M> {
let point = end.point();
let energy_error = point.energy_error();
if energy_error.abs() < self.max_energy_error {
if !math.array_all_finite(point.position()) {
return;
}
if !math.array_all_finite(point.gradient()) {
return;
}
self.draws.push(math.copy_array(point.position()));
self.grads.push(math.copy_array(point.gradient()));
}
@@ -125,6 +131,12 @@ impl<M: Math, P: Point<M>> Collector<M, P> for DrawCollector<M> {
let point = state.point();
let energy_error = point.energy_error();
if energy_error.abs() < self.max_energy_error {
if !math.array_all_finite(point.position()) {
return;
}
if !math.array_all_finite(point.gradient()) {
return;
}
self.draws.push(math.copy_array(point.position()));
self.grads.push(math.copy_array(point.gradient()));
}