In [2]:
require 'image';

In [3]:
itorch.image({image.lena(), image.lena(), image.lena()})


Out[3]:


In [4]:
require 'nn'
m=nn.SpatialConvolution(3,32,25,25)
itorch.image(m.weight)



In [5]:
itorch.audio('volkswagen.mp3')


Out[5]:


In [6]:
itorch.video('small.mp4')


Out[6]:


In [7]:
itorch.html('<p><b>Hi there!</b> this is arbitrary HTML</p>');



In [8]:
x1 = torch.randn(40):mul(100)
y1 = torch.randn(40):mul(100)
x2 = torch.randn(40):mul(100)
y2 = torch.randn(40):mul(100)
x3 = torch.randn(40):mul(200)
y3 = torch.randn(40):mul(200)

In [9]:
Plot = require 'itorch.Plot'

In [10]:
?torch.cmul


Out[10]:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[res] torch.cmul([res,] tensor1, tensor2)


Element-wise multiplication of tensor1 by tensor2 . The number
of elements must match, but sizes do not matter.
 > x = torch.Tensor(2,2):fill(2)
> y = torch.Tensor(4):fill(3)
> x:cmul(y)
> = x
 6  6
 6  6
[torch.Tensor of dimension 2x2] 

 z=torch.cmul(x,y) returns a new tensor.

 torch.cmul(z,x,y) puts the result in z .

 y:cmul(x) multiplies all elements of y with corresponding elements 
of x .

 z:cmul(x,y) puts the result in z .	
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	


In [11]:
plot = Plot():circle(x1, y1, 'red', 'hi'):circle(x2, y2, 'blue', 'bye'):draw()
plot:circle(x3,y3,'green', 'yolo'):redraw()
plot:title('Scatter Plot Demo'):redraw()
plot:xaxis('length'):yaxis('width'):redraw()
plot:legend(true)
plot:redraw()



In [12]:
-- line plots
plot = Plot():line(x1, y1,'red','example'):legend(true):title('Line Plot Demo'):draw()



In [13]:
-- segment plots
plot = Plot():segment(x1, y1, x1+10,y1+10, 'red','demo'):title('Segment Plot Demo'):draw()



In [14]:
-- quiver plots
xx = torch.linspace(-3,3,10)
yy = torch.linspace(-3,3,10)
local function meshgrid(x,y)
   local xx = torch.repeatTensor(x, y:size(1),1)
   local yy = torch.repeatTensor(y:view(-1,1), 1, x:size(1))
    return xx, yy
end
Y, X = meshgrid(xx, yy)
U = -torch.pow(X,2) + Y -1
V =  X - torch.pow(Y,2) +1
plot = Plot():quiver(U,V,'red','',10):title('Quiver Plot Demo'):draw()



In [15]:
-- quads/rectangles
x1=torch.randn(10)
y1=torch.randn(10)
plot = Plot():quad(x1,y1,x1+1,y1+1,'red',''):draw()



In [18]:
-- histogram
x=torch.randn(10000)
lx = torch.log(x):add(1)
plot = Plot():histogram(x):histogram(lx):title('Histogram of a gaussian draw'):draw()



In [17]:



Out[17]:


In [ ]: