Skip to content

Commit

Permalink
minor typo in PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
bshillingford committed Mar 11, 2015
1 parent c6f7a41 commit 96749c8
Showing 1 changed file with 0 additions and 0 deletions.
Binary file modified practical6.pdf
Binary file not shown.

29 comments on commit 96749c8

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep getting this "contiguous tensor" issue running this practical. Any ideas?

~/torch$ th train.lua -vocabfile vocab.t7 -datafile train.t7
-- ignore option print_every
-- ignore option save_every
-- ignore option savefile
-- ignore option vocabfile
-- ignore option datafile
loading data files...
cutting off end of data so that the batches/sequences divide evenly
reshaping tensor...
/home/mark/torch/install/bin/luajit: /home/mark/torch/install/share/lua/5.1/torch/Tensor.lua:450: expecting a contiguous tensor
stack traceback:
[C]: in function 'assert'
/home/mark/torch/install/share/lua/5.1/torch/Tensor.lua:450: in function 'view'
./data/CharLMMinibatchLoader.lua:40: in function 'create'
train.lua:37: in main chunk
[C]: in function 'dofile'
...mark/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:131: in main chunk
[C]: at 0x0804d650

@bshillingford
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your OS and CPU architecture? Make sure you also update torch, in case you have an old installation. There might also be issues from having too new of an installation, but that doesn't seem to be the case.

@mszlazak
Copy link

@mszlazak mszlazak commented on 96749c8 Apr 29, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found another problem. In train.lua within the for-loop of the forward pass, this line:

embeddings[t] = clones.embed[t]:forward(x[{{}, t}])

throws an error:

/home/mark/torch/install/bin/luajit: bad argument #2 to '?' (out of range)
stack traceback:
[C]: at 0xb7341ea0
[C]: in function '__index'
./Embedding.lua:29: in function 'forward'
train.lua:91: in function 'opfunc'
/home/mark/torch/install/share/lua/5.1/optim/adagrad.lua:30: in function 'adagrad'
train.lua:141: in main chunk
[C]: in function 'dofile'
...mark/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:131: in main chunk
[C]: at 0x0804d650

It's related to this line in Embedding:updateOutput(input):
self.output[i]:copy(self.weight[input[i]])
The value of input[i] is a char value, since array input is array x.
This makes no sense??

@bshillingford
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like the issue is a differing binary format between x86 and x86-64. Perhaps a different size for long ints, or the type used to store offsets and strides in the tensors. That would cause the second error, as well.

If you like, I can provide the data in another format, or you can use your own data (see data/ and data_preparation/ for the relevant scripts). Then generate your own vocab.t7 and train.t7. Any large (~50MB or larger) text file will do.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yup that was the suspicion.
When you say "second error" do you mean my last post about Embedding:updateOutput?

Yes please provide it in a different format. The Embedding:updateOutput issue seemed more like a logic issue so another data format would help me resolve it. Thank you!

Here is my email: mszlazak@aol.com

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I get 35 characters. What range of values do i expect. Things I get are arrays with 80's 96's etc. Funny thing is these arrays are filled with just one number.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another side issue while we are at it. If one is not going to flatten everything out like you do then could you not just use the clone() function Torch provides instead the reader() ... etc?

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

th> print(torch.load('vocab.t7'))
{
q : 26
. : 6
c : 12
b : 11
s : 28
d : 13
( : 3
e : 14
t : 29
n : 23
g : 16
w : 32
; : 8
h : 17
, : 5
i : 18
f : 15
y : 34
v : 31
k : 20
j : 19
: 1
? : 9
l : 21
m : 22
! : 2
u : 30
r : 27
o : 24
: : 7
z : 35
x : 33
) : 4
a : 10
p : 25
}

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to keep things as simple as possible at first and do not gather things up into one long storage. It just for teaching/self-learning purposes.

More simply, why not just use clone() provided by Torch instead of reader()?

BTW, see that auto differentiation script you just made. Thanks ... again. LOL

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use something like the following instead of model_utils.clone_many_times,
function makeClones(model, numClones)
local clones = {}
for name, module in pairs(model) do
if module.getParameters then
clones[name] = {}
for i = 1, numClones do
clones[name][i] = module:clone()
end
print('Cloning\t'..#clones[name]..' '..name..' modules.')
end
end
return clones
end

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I will take a look.

BTW, here is a shorter version of Wojciechz code:

https://github.com/wojzaremba/lstm

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mr. Shillingford!
Reading in the files as ascii fixed all the problems.
Have to see whether they fixed the cloning issues with shared parameters ... that was a while back.
Fixing the cloning stuff plus your autobw will make things a lot easier.
https://github.com/bshillingford/autobw.torch

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 1, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! nngraph does not work with the usual parameter names like 'bias', 'weight', etc.

Curious about why you created a getParameters function for multiple modules:
model_utils.combine_all_parameters(...)

If I put protos.embed, protos.lstm, protos.softmax in one module of nngraph then i can get the same thing with getParameters().

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 2, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that is a good reason. However, it does get a bit more complicated in a teaching scenario when learning to use Torch 7. To many "new moving parts" to understand at first and if simpler or familiar ones work then I tend to go that way first.

Also, you used the Embedding package. Does this have the same function as the following in create_network() of https://github.com/wojzaremba/lstm/blob/master/main.lua ?

LookupTable = nn.LookupTable
local i = {[0] = LookupTable(params.vocab_size, params.rnn_size)(x)}

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 2, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, Alex Wiltschko of Harvard is working on a package that is the equivalent of your autobw for all torch tensor operations. Something similar to https://github.com/HIPS/autograd/

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, i sent autobw link to smth chntla and he informed me of Alex working on something similar.

@mszlazak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benjamin Maréchal helped with sharing and getting at nngraph modules/parameters
https://groups.google.com/forum/#!topic/torch7/4f_wMQ6G2io
https://groups.google.com/forum/#!topic/torch7/KheG-Rlfa9k

gModules = {}
for indexNode, node in ipairs(gmod.forwardnodes) do
if node.data.module then
print(node.data.module)
gModules[#gModules+1] = node.data.module
end
end
gModules[1].bias
gModules[1].weight
p, gradP = gModules[1]:getParameters()

@bshillingford
Copy link
Member Author

@bshillingford bshillingford commented on 96749c8 May 4, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.