Skip to content

Instantly share code, notes, and snippets.

@pkulev
Created April 18, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkulev/fa86b2aacdd822b187f7098826c285f9 to your computer and use it in GitHub Desktop.
Save pkulev/fa86b2aacdd822b187f7098826c285f9 to your computer and use it in GitHub Desktop.
>>> def normalize(vector):
... normalized = []
... for elem in vector:
... normalized.append(elem / 255.)
... return normalized
...
>>> normalize((1,2,3))
[0.00392156862745098, 0.00784313725490196, 0.011764705882352941]
>>> normalize((0, 0, 0))
[0.0, 0.0, 0.0]
>>> normalize((255,255,255))
[1.0, 1.0, 1.0]
>>> normalize((128,128,128))
[0.5019607843137255, 0.5019607843137255, 0.5019607843137255]
>>> normalize((128,128,127))
[0.5019607843137255, 0.5019607843137255, 0.4980392156862745]
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment