Compare commits

...

8 Commits

Author SHA1 Message Date
Peter Zhokhov
d1021f5885 Merge branch 'master' of https://github.com/openai/baselines into peterz_import_internal 2018-06-07 14:00:58 -07:00
Peter Zhokhov
6fd15ec92d adding missing tile_images.py 2018-06-07 13:59:58 -07:00
Peter Zhokhov
fab274b9af import internal 2018-06-06 10:34:05 -07:00
Peter Zhokhov
0392dda802 Merge branch 'master' of https://github.com/openai/baselines into peterz_import_internal 2018-06-06 10:33:45 -07:00
Peter Zhokhov
4dc709faae proper rng seeding in the test_identity 2018-05-21 14:46:49 -07:00
Peter Zhokhov
ea55240732 exported commit with identity test 2018-05-21 13:05:39 -07:00
Peter Zhokhov
3d7ed16f1f extra import of the baselines badge 2018-05-16 12:05:35 -07:00
Peter Zhokhov
efb071949e import rl-algs from 2e3a166 commit 2018-05-16 12:00:23 -07:00

View File

@@ -0,0 +1,23 @@
import numpy as np
def tile_images(img_nhwc):
"""
Tile N images into one big PxQ image
(P,Q) are chosen to be as close as possible, and if N
is square, then P=Q.
input: img_nhwc, list or array of images, ndim=4 once turned into array
n = batch index, h = height, w = width, c = channel
returns:
bigim_HWc, ndarray with ndim=3
"""
img_nhwc = np.asarray(img_nhwc)
N, h, w, c = img_nhwc.shape
H = int(np.ceil(np.sqrt(N)))
W = int(np.ceil(float(N)/H))
img_nhwc = np.array(list(img_nhwc) + [img_nhwc[0]*0 for _ in range(N, H*W)])
img_HWhwc = img_nhwc.reshape(H, W, h, w, c)
img_HhWwc = img_HWhwc.transpose(0, 2, 1, 3, 4)
img_Hh_Ww_c = img_HhWwc.reshape(H*h, W*w, c)
return img_Hh_Ww_c