Last active
May 26, 2020 20:33
-
-
Save tswedish/34701dcb3a9b3bd411b82a9292e2f950 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_input_values(self): | |
# calculate the real-valued input to operation | |
return [v.value for v in self.input_variables] | |
def forward(self): | |
# calculate the real-valued output of operation | |
return self.forward_op(*self.calc_input_values()) | |
@property | |
def value(self): | |
return self.forward() | |
@value.setter | |
def value(self, value): | |
if callable(value): | |
self.forward_op = value | |
else: | |
self.forward_op = lambda : value | |
self.derivative_op = create_diff_fn(self.forward_op) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment