Skip to content

Commit 408ea68

Browse files
committed
Merge pull request lisa-lab#72 from nouiz/swapaxes
clarify a section.
2 parents 5b2239c + 8e91dc3 commit 408ea68

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doc/lenet.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ one of Figure 1. The input consists of 3 features maps (an RGB color image) of s
194194

195195
.. code-block:: python
196196

197+
import theano
198+
from theano import tensor as T
197199
from theano.tensor.nnet import conv
200+
201+
import numpy
202+
198203
rng = numpy.random.RandomState(23455)
199204

200205
# instantiate 4D tensor for input
@@ -261,10 +266,11 @@ Let's have a little bit of fun with this...
261266

262267
# open random image of dimensions 639x516
263268
img = Image.open(open('doc/images/3wolfmoon.jpg'))
269+
# dimensions are (height, width, channel)
264270
img = numpy.asarray(img, dtype='float64') / 256.
265271

266272
# put image in 4D tensor of shape (1, 3, height, width)
267-
img_ = img.swapaxes(0, 2).swapaxes(1, 2).reshape(1, 3, 639, 516)
273+
img_ = img.transpose(2, 0, 1).reshape(1, 3, 639, 516)
268274
filtered_img = f(img_)
269275

270276
# plot original image and first and second components of output

0 commit comments

Comments
 (0)