GithubHelp home page GithubHelp logo

tf-helper's Introduction

tf-helper

This is a collection of helper function that I found useful during my work with TensorFlow and Keras.

TODO: Note about purpose and integration of different code bodies.

Getting Started

You can install the library by using pip:

pip install .

After that simply import the library and use according to docs (see below):

import tf_helper as tfh

Note: The library was build and tested against tensorflow-2.0

Docs

The library is split into different sub-modules, based on their purpose:

  • data - all functions relevant to data loading and augmentation (including default datasets)

This section contains a basic overview of the different categories and how the scripts can be used.

Learning

This is for various learning policies and schedulers.

Metrics

Various metrics that are not defined by default in tensorflow/keras.

Visualization

Various functions to visualize learning processes for easier introspection.

Streamlit Callback

This callback shows the general progress of the learning (together with loss data). It also allows to implement the test_step function to provide additional information (e.g. inference tests):

Example:

from visualization.StreamlitCallback import StreamlitCallback

class MyCallback(StreamlitCallback):
  def __init__(self, x_test, class_names=None):
    self._x_test = x_test
    self._names = class_names

  def test_step(self):
    # st.write('**Summary**')
    indices = np.random.choice(len(self._x_test), 36)
    test_data = self._x_test[indices]
    prediction = np.argmax(self.model.predict(test_data), axis=1)
    # update predictions
    if self._names is not None:
      prediction = np.array(self._names)[prediction.astype('int')]

    # display as images
    st.image(1.0 - test_data, caption=prediction)

Data

The data package is currently mainly focused on loading (and storing) data for image processing. This includes classification datasets as well as detection datasets in the kitti format.

Most functions are exposed through the ImageDataset class, which allows to inject the functions directly into the keras and TF dataset APIs.

Example:

# Loading of classification datasets
from data import ImageDataset
from data.utils import ImageSettings

# define the image settings (to generate standardized images)
imgSettings = ImageSettings()
# load the dataset
ds = ImageDataset.loadClasses("/dataset/folder", settings=imgSettings)

# inject the dataset into keras
# TODO

However, there are also some lower level function to manipulate the image data directly (TODO)

Sources

List of research and sources relevant to this repository:

Note: In most cases I have copied and adjusted the code. Notes for that are in the headers of the respective files.

ToDo List

  • Add Jupyter Notebooks to demonstrate usage of individual scripts on dummy data.
  • Update Documentation on the scripts
  • Complete implementation ofdata functions

Research to Implement

  • Single neuron visualization (e.g. lucid)
  • Look Ahead and RAdam Learning Functions

Known Problems

  • Streamlit uses Vega, which can run into problems with Python 3.5.2

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.