Args: dy(CTensor): dL / dy Return: a tuple for (dx0, dx1), dx0 is data for dL / da, dx1 is data for dL / db.
(self, dy)
| 874 | return res |
| 875 | |
| 876 | def backward(self, dy): |
| 877 | """ |
| 878 | Args: |
| 879 | dy(CTensor): dL / dy |
| 880 | Return: |
| 881 | a tuple for (dx0, dx1), dx0 is data for dL / da, dx1 is data |
| 882 | for dL / db. |
| 883 | """ |
| 884 | dx0, dx1 = dy, dy |
| 885 | if (type(dy) == float) or self.shape0 == self.shape1: |
| 886 | assert self.shape0 == self.shape1, ('should have same shape') |
| 887 | return dx0, dx1 |
| 888 | # handle broadcast |
| 889 | dx0 = back_broadcast(self.shape3, self.shape0, dx0) |
| 890 | dx1 = back_broadcast(self.shape3, self.shape1, dx1) |
| 891 | return dx0, dx1 |
| 892 | |
| 893 | |
| 894 | def add(a, b): |
nothing calls this directly
no test coverage detected