src/tensor/loss_ops_PROOF.bend
bendtorch-core@0.1.0.0 · 49 lines · 0 definitions
1import Base
2import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise
3import bendtorch-core@0.1.0.0/src/tensor/loss_ops_LAWS.bend as Laws
4
5def Laws.scalar_divide(left, right):
6 {==}
7
8def Laws.scalar_exp_left(left, right):
9 {==}
10
11def Laws.scalar_log_left(left, right):
12 {==}
13
14def Laws.scalar_matches_same(left, right, same):
15 %Equal.sym(Bool, U32.is_eq(Elementwise.bits(left), Elementwise.bits(right)), True{}, same) :
16 {Elementwise.zero_if(Bool.not(_), 1.0) == 1.0 : F32}
17 {==}
18
19def Laws.scalar_matches_other(left, right, other):
20 %Equal.sym(Bool, U32.is_eq(Elementwise.bits(left), Elementwise.bits(right)), False{}, other) :
21 {Elementwise.zero_if(Bool.not(_), 1.0) == 0.0 : F32}
22 {==}
23
24def Laws.scalar_pick_negated_target(left, right, target):
25 %Equal.sym(Bool, Elementwise.is_one(right), True{}, target) : {Elementwise.zero_if(Bool.not(_), F32.neg(left)) == F32.neg(left) : F32}
26 {==}
27
28def Laws.scalar_pick_negated_other(left, right, other):
29 %Equal.sym(Bool, Elementwise.is_one(right), False{}, other) : {Elementwise.zero_if(Bool.not(_), F32.neg(left)) == 0.0 : F32}
30 {==}
31
32def Laws.scalar_mse_grad(scale, left, right):
33 {==}
34
35def Laws.scalar_one_hot_grad_target(count, left, right, target):
36 %Equal.sym(Bool, Elementwise.is_one(right), True{}, target) :
37 {Elementwise.zero_if(Bool.not(_), Elementwise.target_gradient(left, count)) == F32.neg(F32.div(left, count)) : F32}
38 {==}
39
40def Laws.scalar_one_hot_grad_other(count, left, right, other):
41 %Equal.sym(Bool, Elementwise.is_one(right), False{}, other) :
42 {Elementwise.zero_if(Bool.not(_), Elementwise.target_gradient(left, count)) == 0.0 : F32}
43 {==}
44
45def Laws.scalar_softmax_grad_one_class(count, left, right):
46 {==}
47
48def Laws.scalar_softmax_grad_classes(count, left, right):
49 {==}