Skip to content

Instantly share code, notes, and snippets.

@yatakeke
Last active February 18, 2019 01:53
Show Gist options
  • Save yatakeke/4ed9751be78f50948a740b27f41a86bf to your computer and use it in GitHub Desktop.
Save yatakeke/4ed9751be78f50948a740b27f41a86bf to your computer and use it in GitHub Desktop.
this is the code for step function in Python
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