Skip to content

Commit 187c16c

Browse files
committed
non itorch fixes
1 parent e2c2643 commit 187c16c

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

3_unsupervised/1_data.lua

+5-2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ function displayData(dataset, nsamples, nrow, zoom)
196196
ex[cntr] = exx[1]:clone():unfold(1,math.sqrt(exx[1]:size(1)),math.sqrt(exx[1]:size(1)))
197197
cntr = cntr + 1
198198
end
199-
200-
itorch.image(ex)
199+
if itorch then
200+
itorch.image(ex)
201+
else
202+
print('For visualization, run the script in itorch')
203+
end
201204
end

4_graphicalmodels/2_crf.lua

+17-11
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ do
4646
X = X + randn(X:size())/2
4747

4848
-- display a couple of input examples
49-
print('training examples visualization:')
50-
itorch.image({
51-
X[1]:reshape(32,32),
52-
X[2]:reshape(32,32),
53-
X[3]:reshape(32,32),
54-
X[4]:reshape(32,32)
55-
})
49+
if itorch then
50+
print('training examples visualization:')
51+
itorch.image({
52+
X[1]:reshape(32,32),
53+
X[2]:reshape(32,32),
54+
X[3]:reshape(32,32),
55+
X[4]:reshape(32,32)
56+
})
57+
end
5658

5759
-- define adjacency matrix (4-connexity lattice)
5860
local adj = gm.adjacency.lattice2d(nRows,nCols,4)
@@ -144,11 +146,15 @@ do
144146
end
145147

146148
-- display
147-
print('marginals:')
148-
itorch.image(marginals)
149+
if itorch then
150+
print('marginals:')
151+
itorch.image(marginals)
152+
end
149153
for _,labeling in ipairs(labelings) do
150154
labeling:add(-1)
151155
end
152-
print('labelings:')
153-
itorch.image(labelings)
156+
if itorch then
157+
print('labelings:')
158+
itorch.image(labelings)
159+
end
154160
end

0 commit comments

Comments
 (0)