Commit 08c41772 authored by Geoff Pleiss's avatar Geoff Pleiss Committed by Soumith Chintala
Browse files

`make_grid` doesn't exclude last images in python2 (#95)

In python2, calling `make_grid` won't display the last images if the number of images doesn't divide `nrow`.
Int division...

This should fix that!
parent 6fc69a42
...@@ -27,7 +27,7 @@ def make_grid(tensor, nrow=8, padding=2): ...@@ -27,7 +27,7 @@ def make_grid(tensor, nrow=8, padding=2):
# make the mini-batch of images into a grid # make the mini-batch of images into a grid
nmaps = tensor.size(0) nmaps = tensor.size(0)
xmaps = min(nrow, nmaps) xmaps = min(nrow, nmaps)
ymaps = int(math.ceil(nmaps / xmaps)) ymaps = int(math.ceil(float(nmaps) / xmaps))
height, width = int(tensor.size(2) + padding), int(tensor.size(3) + padding) height, width = int(tensor.size(2) + padding), int(tensor.size(3) + padding)
grid = tensor.new(3, height * ymaps, width * xmaps).fill_(tensor.max()) grid = tensor.new(3, height * ymaps, width * xmaps).fill_(tensor.max())
k = 0 k = 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment