- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiv.java
More file actions
Latest commit
23 lines (23 loc) · 424 Bytes
/
Copy pathdiv.java
File metadata and controls
23 lines (23 loc) · 424 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
packagebasicops;
importjava.util.*;
importjava.math.*;
publicclassdiv
{
tensornum1;
tensornum2;
publicdiv(tensora,tensorb)
{
num1=a;
num2=b;
}
publictensorforward()
{
tensorevaltensor=newtensor(num1.data/num2.data,false);
returnevaltensor;
}
publicvoidbackward(tensorbackflow)
{
num1.grad+=backflow.grad*(1/num2.data);
num2.grad+=backflow.grad*(-num1.data/Math.pow(num2.data,2));
}
}