From: @shallydeng Reviewed-by: @zichun_ye,@wang_zi_dong Signed-off-by: @zichun_yetags/v1.1.0
| @@ -34,17 +34,17 @@ class Exp(PowerTransform): | |||||
| >>> | >>> | ||||
| >>> # To use an Exp bijector in a network. | >>> # To use an Exp bijector in a network. | ||||
| >>> class net(Cell): | >>> class net(Cell): | ||||
| >>> def __init__(self): | |||||
| >>> super(net, self).__init__(): | |||||
| >>> self.e1 = msb.Exp() | |||||
| >>> | |||||
| >>> def construct(self, value): | |||||
| >>> # Similar calls can be made to other functions | |||||
| >>> # by replacing `forward` by the name of the function. | |||||
| >>> ans1 = self.s1.forward(value) | |||||
| >>> ans2 = self.s1.inverse(value) | |||||
| >>> ans3 = self.s1.forward_log_jacobian(value) | |||||
| >>> ans4 = self.s1.inverse_log_jacobian(value) | |||||
| ... def __init__(self): | |||||
| ... super(net, self).__init__(): | |||||
| ... self.e1 = msb.Exp() | |||||
| ... | |||||
| ... def construct(self, value): | |||||
| ... # Similar calls can be made to other functions | |||||
| ... # by replacing `forward` by the name of the function. | |||||
| ... ans1 = self.s1.forward(value) | |||||
| ... ans2 = self.s1.inverse(value) | |||||
| ... ans3 = self.s1.forward_log_jacobian(value) | |||||
| ... ans4 = self.s1.inverse_log_jacobian(value) | |||||
| """ | """ | ||||
| def __init__(self, | def __init__(self, | ||||
| @@ -42,17 +42,17 @@ class GumbelCDF(Bijector): | |||||
| >>> | >>> | ||||
| >>> # To use GumbelCDF bijector in a network. | >>> # To use GumbelCDF bijector in a network. | ||||
| >>> class net(Cell): | >>> class net(Cell): | ||||
| >>> def __init__(self): | |||||
| >>> super(net, self).__init__(): | |||||
| >>> self.gum = msb.GumbelCDF(0.0, 1.0) | |||||
| >>> | |||||
| >>> def construct(self, value): | |||||
| >>> # Similar calls can be made to other functions | |||||
| >>> # by replacing 'forward' by the name of the function. | |||||
| >>> ans1 = self.gum.forward(value) | |||||
| >>> ans2 = self.gum.inverse(value) | |||||
| >>> ans3 = self.gum.forward_log_jacobian(value) | |||||
| >>> ans4 = self.gum.inverse_log_jacobian(value) | |||||
| ... def __init__(self): | |||||
| ... super(net, self).__init__(): | |||||
| ... self.gum = msb.GumbelCDF(0.0, 1.0) | |||||
| ... | |||||
| ... def construct(self, value): | |||||
| ... # Similar calls can be made to other functions | |||||
| ... # by replacing 'forward' by the name of the function. | |||||
| ... ans1 = self.gum.forward(value) | |||||
| ... ans2 = self.gum.inverse(value) | |||||
| ... ans3 = self.gum.forward_log_jacobian(value) | |||||
| ... ans4 = self.gum.inverse_log_jacobian(value) | |||||
| """ | """ | ||||
| def __init__(self, | def __init__(self, | ||||
| @@ -28,21 +28,21 @@ class Invert(Bijector): | |||||
| Examples: | Examples: | ||||
| >>> # To initialize an Invert bijector. | >>> # To initialize an Invert bijector. | ||||
| >>> import mindspore.nn.probability.bijector as msb | >>> import mindspore.nn.probability.bijector as msb | ||||
| >>> n = msb.Invert() | |||||
| >>> n = msb.Invert(msb.Exp()) | |||||
| >>> | >>> | ||||
| >>> # To use an Invert bijector in a network. | >>> # To use an Invert bijector in a network. | ||||
| >>> class net(Cell): | >>> class net(Cell): | ||||
| >>> def __init__(self): | |||||
| >>> super(net, self).__init__(): | |||||
| >>> self.inv = msb.Invert(msb.Exp()) | |||||
| >>> | |||||
| >>> def construct(self, value): | |||||
| >>> # Similar calls can be made to other functions | |||||
| >>> # by replacing `forward` by the name of the function. | |||||
| >>> ans1 = self.inv.forward(value) | |||||
| >>> ans2 = self.inv.inverse(value) | |||||
| >>> ans3 = self.inv.forward_log_jacobian(value) | |||||
| >>> ans4 = self.inv.inverse_log_jacobian(value) | |||||
| ... def __init__(self): | |||||
| ... super(net, self).__init__(): | |||||
| ... self.inv = msb.Invert(msb.Exp()) | |||||
| ... | |||||
| ... def construct(self, value): | |||||
| ... # Similar calls can be made to other functions | |||||
| ... # by replacing `forward` by the name of the function. | |||||
| ... ans1 = self.inv.forward(value) | |||||
| ... ans2 = self.inv.inverse(value) | |||||
| ... ans3 = self.inv.forward_log_jacobian(value) | |||||
| ... ans4 = self.inv.inverse_log_jacobian(value) | |||||
| """ | """ | ||||
| def __init__(self, | def __init__(self, | ||||
| @@ -46,17 +46,17 @@ class PowerTransform(Bijector): | |||||
| >>> | >>> | ||||
| >>> # To use a PowerTransform bijector in a network. | >>> # To use a PowerTransform bijector in a network. | ||||
| >>> class net(Cell): | >>> class net(Cell): | ||||
| >>> def __init__(self): | |||||
| >>> super(net, self).__init__(): | |||||
| >>> self.p1 = msb.PowerTransform(0.5) | |||||
| >>> | |||||
| >>> def construct(self, value): | |||||
| >>> # Similar calls can be made to other functions | |||||
| >>> # by replacing 'forward' by the name of the function. | |||||
| >>> ans1 = self.s1.forward(value) | |||||
| >>> ans2 = self.s1.inverse(value) | |||||
| >>> ans3 = self.s1.forward_log_jacobian(value) | |||||
| >>> ans4 = self.s1.inverse_log_jacobian(value) | |||||
| ... def __init__(self): | |||||
| ... super(net, self).__init__(): | |||||
| ... self.p1 = msb.PowerTransform(0.5) | |||||
| ... | |||||
| ... def construct(self, value): | |||||
| ... # Similar calls can be made to other functions | |||||
| ... # by replacing 'forward' by the name of the function. | |||||
| ... ans1 = self.s1.forward(value) | |||||
| ... ans2 = self.s1.inverse(value) | |||||
| ... ans3 = self.s1.forward_log_jacobian(value) | |||||
| ... ans4 = self.s1.inverse_log_jacobian(value) | |||||
| """ | """ | ||||
| def __init__(self, | def __init__(self, | ||||
| @@ -42,17 +42,17 @@ class ScalarAffine(Bijector): | |||||
| >>> | >>> | ||||
| >>> # To use a ScalarAffine bijector in a network. | >>> # To use a ScalarAffine bijector in a network. | ||||
| >>> class net(Cell): | >>> class net(Cell): | ||||
| >>> def __init__(self): | |||||
| >>> super(net, self).__init__(): | |||||
| >>> self.s1 = nn.probability.bijector.ScalarAffine(1, 2) | |||||
| >>> | |||||
| >>> def construct(self, value): | |||||
| >>> # Similar calls can be made to other functions | |||||
| >>> # by replacing 'forward' by the name of the function. | |||||
| >>> ans1 = self.s1.forward(value) | |||||
| >>> ans2 = self.s1.inverse(value) | |||||
| >>> ans3 = self.s1.forward_log_jacobian(value) | |||||
| >>> ans4 = self.s1.inverse_log_jacobian(value) | |||||
| ... def __init__(self): | |||||
| ... super(net, self).__init__(): | |||||
| ... self.s1 = nn.probability.bijector.ScalarAffine(1, 2) | |||||
| ... | |||||
| ... def construct(self, value): | |||||
| ... # Similar calls can be made to other functions | |||||
| ... # by replacing 'forward' by the name of the function. | |||||
| ... ans1 = self.s1.forward(value) | |||||
| ... ans2 = self.s1.inverse(value) | |||||
| ... ans3 = self.s1.forward_log_jacobian(value) | |||||
| ... ans4 = self.s1.inverse_log_jacobian(value) | |||||
| """ | """ | ||||
| def __init__(self, | def __init__(self, | ||||
| @@ -35,21 +35,21 @@ class Softplus(Bijector): | |||||
| Examples: | Examples: | ||||
| >>> # To initialize a Softplus bijector of sharpness 2. | >>> # To initialize a Softplus bijector of sharpness 2. | ||||
| >>> softplus = nn.probability.bijector.Softfplus(2) | |||||
| >>> softplus = nn.probability.bijector.Softplus(2) | |||||
| >>> | >>> | ||||
| >>> # To use ScalarAffine bijector in a network. | >>> # To use ScalarAffine bijector in a network. | ||||
| >>> class net(Cell): | >>> class net(Cell): | ||||
| >>> def __init__(self): | |||||
| >>> super(net, self).__init__(): | |||||
| >>> self.sp1 = nn.probability.bijector.Softflus(2) | |||||
| >>> | |||||
| >>> def construct(self, value): | |||||
| >>> # Similar calls can be made to other functions | |||||
| >>> # by replacing 'forward' by the name of the function. | |||||
| >>> ans1 = self.sp1.forward(value) | |||||
| >>> ans2 = self.sp1.inverse(value) | |||||
| >>> ans3 = self.sp1.forward_log_jacobian(value) | |||||
| >>> ans4 = self.sp1.inverse_log_jacobian(value) | |||||
| ... def __init__(self): | |||||
| ... super(net, self).__init__(): | |||||
| ... self.sp1 = nn.probability.bijector.Softplus(2.) | |||||
| ... | |||||
| ... def construct(self, value): | |||||
| ... # Similar calls can be made to other functions | |||||
| ... # by replacing 'forward' by the name of the function. | |||||
| ... ans1 = self.sp1.forward(value) | |||||
| ... ans2 = self.sp1.inverse(value) | |||||
| ... ans3 = self.sp1.forward_log_jacobian(value) | |||||
| ... ans4 = self.sp1.inverse_log_jacobian(value) | |||||
| """ | """ | ||||
| def __init__(self, | def __init__(self, | ||||