Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution/task 0 1 #4

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions minitorch/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def sigmoid(x: float) -> float:
for stability.
"""
# TODO: Implement for Task 0.1.
raise NotImplementedError("Need to implement for Task 0.1")
return (1.0 / (1.0 + math.exp(-x))) if x >= 0 else math.exp(x) / (1 + math.exp(x))


def relu(x: float) -> float:
Expand Down Expand Up @@ -103,7 +103,7 @@ def exp(x: float) -> float:
def log_back(x: float, d: float) -> float:
r"If $f = log$ as above, compute $d \times f'(x)$"
# TODO: Implement for Task 0.1.
raise NotImplementedError("Need to implement for Task 0.1")
return d / x


def inv(x: float) -> float:
Expand All @@ -116,7 +116,7 @@ def inv(x: float) -> float:
def inv_back(x: float, d: float) -> float:
r"If $f(x) = 1/x$ compute $d \times f'(x)$"
# TODO: Implement for Task 0.1.
raise NotImplementedError("Need to implement for Task 0.1")
return -(x ** (-2)) * d


def relu_back(x: float, d: float) -> float:
Expand Down
Loading