Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
I have added the utility of
__pow__(self , other)
__rpow__(self , other)
methods where it can now use the base as well as the exponent asValue
objects. It also allows for flow of gradient throughself
orother
if it is ofValue
object, else gradient is not calculated for them.Why
This allows the
__pow__(self,other)
to be similar to the other basic methods like__add__(self,other)
,__mul__(self,other)__
, etc. which allows for both the inputs to beValue
objects or one of them to beValue
and the other to be any numeric type.How
The implementation was very basic and was implemented using the basic
__pow__
and__rpow__
magic methods.Testing
I tested with the following three scenarios and I have pasted the results from console for rechecking.
First scenario
Output
Second scenario
Output
Third scenario
Output
@karpathy please review!