Skip to content

Instantly share code, notes, and snippets.

@eigenfoo
Created February 9, 2019 04:01
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 eigenfoo/4737fd9e891f6495d61ddb9112136c93 to your computer and use it in GitHub Desktop.
Save eigenfoo/4737fd9e891f6495d61ddb9112136c93 to your computer and use it in GitHub Desktop.
#!bin/python
import numpy as np
batch_size = 32
image_height = 256
image_width = 256
num_channels = 3
# You can think of multi-dimensional arrays (a.k.a. ndarrays or tensors) as
# nested list comprehensions.
x = [[[[np.random.randint(255) for _ in range(num_channels)]
for _ in range(image_width)]
for _ in range(image_height)]
for _ in range(batch_size)]
x = np.array(x)
assert x.shape == (batch_size, image_height, image_width, num_channels)
# This might seem trivial but it gives us a systematic way of thinking about
# high-dimensional arrays. There are two things to understand: what one
# particular value looks like, and how these values are arranged together.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment