Comments (9)
@GooShan I think I fixed that bug a few minutes ago.
from torchnet.
When I check the torchnet codes, I found that, in listdataset.lua, line 116, for different of list, it should be different. When list is a table, #self.list should be a number, but when list is LongTensor , #self.list is a tensor. Am I right? Maybe this caused the problem.
from torchnet.
No this does look like a serialization issue that arises when you're creating the ParallelDatasetIterator
. This creates a number of threads; at thread construction time, upvalues are serialized. Can you post a repro? Also, please make sure your threads
package is up-to-date.
from torchnet.
Hello,
I have the same issue when running on fresh Torch+Torchnet + dependencies install
Installed rocks:
argcheck: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
cwrap: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
dok: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
env: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
fftw3: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
gnuplot: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
graph: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
graphicsmagick: 1.scm-0 (installed) - /home/x/torch/install/lib/luarocks/rocks
image: 1.1.alpha-0 (installed) - /home/x/torch/install/lib/luarocks/rocks
lua-cjson: 2.1devel-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
luaffi: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
luafilesystem: 1.6.3-2 (installed) - /home/x/torch/install/lib/luarocks/rocks
luasocket: 2.0rc1-2 (installed) - /home/x/torch/install/lib/luarocks/rocks
md5: 1.2-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
mnist: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
nn: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
nngraph: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
nnx: 0.1-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
optim: 1.0.5-0 (installed) - /home/x/torch/install/lib/luarocks/rocks
paths: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
penlight: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
qtlua: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
qttorch: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
signal: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
sundown: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
sys: 1.1-0 (installed) - /home/x/torch/install/lib/luarocks/rocks
tds: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
threads: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
torch: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
torchnet: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
trepl: scm-1 (installed) - /home/x/torch/install/lib/luarocks/rocks
xlua: 1.0-0 (installed) - /home/x/torch/install/lib/luarocks/rocks
from torchnet.
Hi, I am facing the same problem with ParallelDatasetIterator
. I did a clean new install of torch
and installed threads
. Can any other library cause the serialization problem?
Is there something similar to pip freeze
in Lua? It would be great if we can post the packages and their versions here.
from torchnet.
Apparently, the mnist
package is not serializable, perhaps because it contains objects that live in C-land, which is why you cannot do this. The solution is to not serialize the mnist
object, by putting the content of loadmnist
in the closure
function (this way, the mnist
package will be loaded inside each thread instead of being serialized).
from torchnet.
As hinted by @byronwwang there is an actual bug in listdataset.lua, however, it is on line 126. When a torch.LongTensor is provided the assert statement fails with "
both (null) and torch.LongTensor have no less-equal operator"
.
The assert statement should be modified for the case of LongTensor by using :size(1)
instead of #
. The second option, which I am using, is to convert my list from LongTensor
to Lua table
with torch.totable()
from torchnet.
It appears the example in the paper was done for a different version of the mnist
package. This code example should work fine:
local tnt = require 'torchnet'
local function getIterator(mode)
return tnt.ParallelDatasetIterator{
nthread = 1,
init = function() require 'torchnet' end,
closure = function()
local mnist = require 'mnist'
local dataset = mnist[mode .. 'dataset']()
dataset.data = dataset.data:reshape(
dataset.data:size(1),
dataset.data:size(2) *
dataset.data:size(3)
):double()
return tnt.BatchDataset{
batchsize = 128,
dataset = tnt.ListDataset{
list = torch.range(
1, dataset.data:size(1)
):long(),
load = function(idx)
return {
input = dataset.data[idx],
target = torch.LongTensor{
dataset.label[idx] + 1
},
} -- sample contains input and target
end,
}
}
end,
}
end
local net = nn.Sequential():add(nn.Linear(784,10))
local engine = tnt.SGDEngine()
local meter = tnt.AverageValueMeter()
local clerr = tnt.ClassErrorMeter{topk = {1}}
engine.hooks.onStartEpoch = function(state)
meter:reset()
clerr:reset()
end
engine.hooks.onForwardCriterion =
function(state)
meter:add(state.criterion.output)
clerr:add(
state.network.output, state.sample.target)
print(string.format(
'avg. loss: %2.4f; avg. error: %2.4f',
meter:value(), clerr:value{k = 1}))
end
local criterion = nn.CrossEntropyCriterion()
engine:train{
network = net,
iterator = getIterator('train'),
criterion = criterion,
lr = 0.1,
maxepoch = 10,
}
engine:test{
network = net,
iterator = getIterator('test'),
criterion = criterion,
}
I will add it to the codebase.
from torchnet.
See https://github.com/torchnet/torchnet/blob/master/example/mnist.lua for a working example with comments.
from torchnet.
Related Issues (20)
- Document uncorrect about "transform.perm"
- for ListDataset, add an onComplete argument HOT 2
- OptimEngine.test not implemented HOT 2
- fatal thread panic on parallelDatasetIterator HOT 1
- Improve ParallelDatasetIterator documentation HOT 13
- How can i use MSE criterion? HOT 5
- IndexedDataset using string as index for large dataset HOT 4
- returning vector in ListDataset problem. HOT 2
- This error is unclear - what is the problem with my code that is causing this? HOT 3
- Segmentation fault (core dumped) HOT 8
- Bug report: not entering into iterator until thorough depth. HOT 2
- ClassErrorMeter throwing size mismatch error HOT 1
- meter.MultilabelConfusionMeter invalid argument error HOT 1
- some bugs of transform.merge() HOT 1
- bug in transform.tablemergekeys() HOT 1
- Unable to install qlua, and therefore: qlua: module 'torchnet' not found HOT 1
- Hi, I doubt that whether I can use torchnet in win10 64x. Could anybody tell me? HOT 2
- "not enough memory" with small dataset when nthread>1 for ParallelDatasetIterator HOT 4
- How to add torchnet to a custom package on kaggle HOT 1
- RecursionError with meter.ConfusionMeter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torchnet.