Code Monkey home page Code Monkey logo

Comments (4)

lvdmaaten avatar lvdmaaten commented on August 13, 2024

Note that d = d:shuffle() is syntactic sugar for doing d = tnt.ShuffleDataset{dataset = d}. So of course select() is gone in d.

Can't you do e = d:shuffle() and get samples from e:iterator()?

from torchnet.

Cadene avatar Cadene commented on August 13, 2024

It works now, thanks 👍

local tnt = require 'torchnet'

local d = tnt.TableDataset{data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}

d = d:split{
  train = 0.7,
  val   = 0.3
}

d:select('val')
print('val')
for sample in d:iterator()() do
  print(sample)
end

d:select('train')
print('train')
for sample in d:iterator()() do
  print(sample)
end

trainset=d:shuffle()
print('train2')
for sample in trainset:iterator()() do
  print(sample)
end

d:select('val')
testset=d:shuffle()
print('val2')
for sample in testset:iterator()() do
  print(sample)
end

from torchnet.

lvdmaaten avatar lvdmaaten commented on August 13, 2024

Be careful with this though! Your call to d:select('val') also changes trainset because SplitDataset.select is not actually cloning. So both trainset and testset have the same underlying dataset d, with the same partition selected at any point in time.

We may have to consider changing SplitDataset to actually return a table of Datasets to prevent these kinds of bugs from occurring.

from torchnet.

Cadene avatar Cadene commented on August 13, 2024

Oh so it didn't solve the problem. That's what I thought in the first place. I really think returning a table of Dataset is a good idea.

I found this issue thinking about a possible BootstrapDataset which could split a Dataset in two partitions :

  • the first one (train) would be made with a shuffle{remplacement=true} call,
  • the second one (val) would be made from all the non picked samples from the first partition.

from torchnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.