Git Product home page Git Product logo

main_loop_tf's Introduction

A main loop to use Tensorflow with custom data not in the protobuf format. This code is optimized to work coupled with the dataset loaders, a framework to load and preprocess your data with parallel threads.

Attribution

If you use this code, please cite:

  • [1] Francesco Visin - Main loop TF: a main loop for Tensorflow and custom data (BibTeX)

If you use the Dataset loaders, please also cite:

  • [1] Francesco Visin, Adriana Romero - Dataset loaders: a python library to load and preprocess datasets (BibTeX)

Usage

To use the main loop, simply create a file with this code and call it.

if __name__ == '__main__':
    import sys

    from main_loop_tf.main import run

    from model import build_model

    argv = sys.argv
    # Here you can potentially put some constant params you want to pass to the
    # main loop
    run(argv, build_model)

How to add your own parameters

To add some model specific parameters to the list of parameters, just specify them in your model file with the usual gflags syntax:

    import gflags

    gflags.DEFINE_integer('my_custom_param', 0, 'This sets up a custom param')

    def build_model():
        cfg = gflags.cfg
        print('This is your param value {}'.format(cfg.my_custom_param))
        pass

You can find a list of DEFINE* methods here

You can also flag some options as required with:

    gflags.mark_flag_as_required('required1')
    gflags.mark_flags_as_required(['required1', 'required2])

How to add lists of lists

To add list of lists (e.g. [[10, 10], [20, 20]]) you can use the gflags extensions in gflags_ext:

import gflags
import sys
from main_loop_tf import gflags_ext

gflags_ext.DEFINE_intlist('a', [[10, 10], [20, 20]], 'A list of ints')

See gflags_ext for the other DEFINEs.

Notes

  • The code is provided as is, please expect minimal-to-none support on it.
  • This code is provided for research purposes only. Although we tried our best to test it, the code might be bugged or unstable. Use it at your own risk!
  • PRs welcome!! Feel free to contribute to the code with a PR if you find bugs or want to improve the existing code!



THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

main_loop_tf's People

Contributors

fvisin avatar marcociccone avatar fral92 avatar

Watchers

 avatar

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.