Skip to content

Commit

Permalink
Fxied demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
clementfarabet committed Jun 19, 2012
1 parent bff6e2b commit 4d12628
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions tensors/slicing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ function next()
print ''
end

next()
print '----------------------------------------------------------------------'
print 'creating a few tensors'

t1 = torch.Tensor(3,5,5):zero()
t1 = torch.zeros(3,5,5)
print 't1 = torch.zeros(3,5,5)'
t1 = torch.range(1,75):resize(3,5,5)
print 't1 = torch.range(1,75):resize(3,5,5)'
print 't1 = '
print(t2)
print(t1)

t2 = torch.range(1,25):resize(5,5)
print 't2 = torch.range(1,25):resize(5,5)'
Expand All @@ -48,25 +46,23 @@ print '----------------------------------------------------------------------'
print 'the most basic slicing is done using the [] operator'
print ''

t1_1 = t1[2]

print 't1 ='
print( t1 )

print 't1[1] ='
print( t1_1 )
print 't1[2] ='
print( t1[2] )

next()
print '----------------------------------------------------------------------'
print 't1_1 is a view in the existing t1 tensor: changing the values'
print 'in t1_1 directly affects t1:'
print ''

t1_1:fill(7)
print 't1_1:fill(7)'
t1[2]:fill(7)
print 't1[2]:fill(7)'

print 't1[1] ='
print( t1_1 )
print 't1[2] ='
print( t1[2] )

print 't1 ='
print( t1 )
Expand Down

0 comments on commit 4d12628

Please sign in to comment.