You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Stacks replicated, shifted versions of x_inp-- into a single matrix of size x_inp:size(1) x batch_size.localfunctionreplicate(x_inp, batch_size)
locals=x_inp:size(1)
localx=torch.zeros(torch.floor(s/batch_size), batch_size)
fori=1, batch_sizedolocalstart=torch.round((i-1) *s/batch_size) +1localfinish=start+x:size(1) -1x:sub(1, x:size(1), i, i):copy(x_inp:sub(start, finish))
endreturnxend
Fom the comment I expected that the output would be a matrix of size number_of_words by batch_size
But the output is torch.floor(s / batch_size)by batch_size
If i load the first 5 lines from ptb.train.txt x is:
x:view(14, 8) -- change view for printing12345678910111213141516171819202122232425262728293031323334353637383928254027414243274433454647254827282930495042435152535455563637384357585960253661436263646566676869707136727343747576364743777865798081282982838425
[torch.DoubleTensorofsize14x8]
local nBatches = torch.floor(data:size(1)/batchSize)
local x = torch.zeros(nBatches, batchSize)
for i = 1, batchSize do
local start = (i-1) * nBatches + 1
local finish = i * nBatches
x:sub(1, nBatches, i, i):copy(data:sub(start, finish))
end
I'm having trouble understanding
replicate
.Fom the comment I expected that the output would be a matrix of size
number_of_words
bybatch_size
But the output is
torch.floor(s / batch_size)
bybatch_size
If i load the first 5 lines from
ptb.train.txt
x is:And the output from from replicate is:
Why is every second column shifted one? e.g 5-7, 11-12, 16-18, 22-23 etc?
The text was updated successfully, but these errors were encountered: