forked from tracel-ai/burn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c050c2
commit ef01a4e
Showing
15 changed files
with
71 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ mod cat; | |
mod creation; | ||
mod erf; | ||
mod module; | ||
mod pow; | ||
mod tensor; | ||
|
||
mod macros; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
mod cat; | ||
mod creation; | ||
mod erf; | ||
mod pow; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
mod cat; | ||
mod creation; | ||
mod erf; | ||
mod pow; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ mod mask; | |
mod matmul; | ||
mod mul; | ||
mod neg; | ||
mod pow; | ||
mod reshape; | ||
mod softmax; | ||
mod sub; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::tensor::TestADTensor; | ||
use burn_tensor::Data; | ||
|
||
#[test] | ||
fn should_diff_powf() { | ||
let data_1 = Data::<f32, 2>::from([[0.0, 1.0], [3.0, 4.0]]); | ||
let data_2 = Data::<f32, 2>::from([[6.0, 7.0], [9.0, 10.0]]); | ||
|
||
let tensor_1 = TestADTensor::from_data(data_1); | ||
let tensor_2 = TestADTensor::from_data(data_2); | ||
|
||
let tensor_3 = tensor_1.matmul(&tensor_2.powf(0.4)); | ||
let tensor_4 = tensor_3.matmul(&tensor_2); | ||
let grads = tensor_4.backward(); | ||
|
||
let grad_1 = tensor_1.grad(&grads).unwrap(); | ||
let grad_2 = tensor_2.grad(&grads).unwrap(); | ||
|
||
grad_1 | ||
.to_data() | ||
.assert_approx_eq(&Data::from([[68.0, 79.0328], [68.0, 79.0328]]), 3); | ||
grad_2 | ||
.to_data() | ||
.assert_approx_eq(&Data::from([[23.5081, 25.2779], [26.0502, 28.6383]]), 3); | ||
} |