Last active
February 18, 2019 01:53
-
-
Save yatakeke/4ed9751be78f50948a740b27f41a86bf to your computer and use it in GitHub Desktop.
this is the code for step function in Python
This file contains hidden or 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 step_function(x): | |
return np.where(x >= 0, 1, 0) | |
### It is equivalent to below code to give 1-D array to np.where. | |
### variables = np.where(condition, val1, val2) <=> variables = val1 if x >= 0 else val2 | |
def step_function(x:list): | |
return np.maximum(x, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment