GithubHelp home page GithubHelp logo

Comments (2)

hswick avatar hswick commented on June 15, 2024 1

I made attempts at this before and ran into the same complexity. I actually think the best way to do is to write some java code to make a more clojure friendly DataSetIterator

from jutsu.ai.

behrica avatar behrica commented on June 15, 2024

I did something like this in parts
The snippet below takes "features" as a vector of maps,
and "y" as a vector of targets
and it will create an NDArray
and then a DataSet and then a DataSetIterator
which could be used with the existing method "train-net!"

(def data (Nd4j/create (into-array (map double-array (map vals features))))
 (def labels (.transpose (Nd4j/create y)))
(def data-set (DataSet. data labels))

.. split  "data-set" into test and train

(def dataset-iterator (ViewIterator. train-data-set 1000) 10))

What makes it complex, is that the logic of

  • epochs
  • batches vs. mini-batches
  • in-memory vs stream data from disk
  • test-train split
  • normalization

is all
encapsulated or uses the DataSetIterator interface, so it has lots of implementations, and the user needs to be able to choose and configure them.

To have this functionality fully on the Clojure site, a lot of implementations of DatasetIterator
logic needed to be ported to Clojure:
https://deeplearning4j.org/api/latest/org/nd4j/linalg/dataset/api/iterator/DataSetIterator.html

And this code is very much state-full OO style, so hard to make functional.

But maybe a single function , implementing "one scenario",
like

(defn iterate-data [features (vector of maps)   labels (vector)   test-train-split-percentage num-batches num-epochs)

-> returns 2  data-set iterators (for train and test)

could be useful. And it would not required any change in existing methods, as they can already handle any DataSetIterator

from jutsu.ai.

Related Issues (10)

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.