Answering this question on Cross Validated.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
""" | |
Given a 4D array of shape (n, h, w, c) representing n images of shape (h, w, c), | |
make a single image consisting of a regular grid of smaller images. | |
License: MIT No attribution | |
""" | |
import numpy as np | |
def reshape(arr, rows, cols, pixels=False): | |
"""Reshapes a 4D array into a grid of images. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Properties of the scaled standard deviational hyperellipsoid. | |
# | |
# Author: Matt Hall, [email protected] | |
# Copyright: 2022, Matt Hall | |
# Licence: Apache 2.0, https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# These small functions implement n-dimensional lookup of the beta-distribution | |
# approximation to this problem. They answer the questions, "What proportion | |
# of a multivariate Gaussian distribution is contained by `r` standard | |
# deviations?" and "How many standard deviations contain a proportion `p` of |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# We want to get unique items in a sequence, but to keep the order in which they appear. | |
# There are quite a few solutions here > http://www.peterbe.com/plog/uniqifiers-benchmark | |
# Good, up to date summary of methods > https://stackoverflow.com/a/17016257/3381305 | |
# Some test data: text... | |
tdat = 100 * ['c', 'a', 'c', 'b', 'e', 'd', 'f', 'g', 'h', 'i', 'j', 'j'] | |
tarr = np.array(tdat) | |
tser = pd.Series(tdat) | |
# ... and numbers. | |
narr = np.random.randint(0, 10, size=1200) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.