Home

Awesome

<div align="center"> <img src="https://raw.githubusercontent.com/eaplatanios/tensorflow_scala/master/docs/images/logo.svg?sanitize=true" width="350px" height="242px"><br> </div>

CircleCI Codacy Badge License API Docs JNI Docs Data Docs Examples Docs

This library is a Scala API for https://www.tensorflow.org. It attempts to provide most of the functionality provided by the official Python API, while at the same type being strongly-typed and adding some new features. It is a work in progress and a project I started working on for my personal research purposes. Much of the API should be relatively stable by now, but things are still likely to change.

Chat Room

Please refer to the main website for documentation and tutorials. Here are a few useful links:

Citation

It would be greatly appreciated if you could cite this project using the following BibTex entry, if you end up using it in your work:

@misc{Platanios:2018:tensorflow-scala,
  title        = {{TensorFlow Scala}},
  author       = {Platanios, Emmanouil Antonios},
  howpublished = {\url{https://github.com/eaplatanios/tensorflow_scala}},
  year         = {2018}
}

Main Features

Compiling from Source

Note that in order to compile TensorFlow Scala on your machine you will need to first install the TensorFlow Python API. You also need to make sure that you have a python3 alias for your python binary. This is used by CMake to find the TensorFlow header files in your installation.

Tutorials

Funding

Funding for the development of this library has been generously provided by the following sponsors:

<img src="https://platanios.org/tensorflow_scala/assets/images/cmu_logo.svg" alt="cmu_logo" width="200px" height="150px"><img src="https://platanios.org/tensorflow_scala/assets/images/nsf_logo.svg" alt="nsf_logo" width="150px" height="150px"><img src="https://platanios.org/tensorflow_scala/assets/images/afosr_logo.gif" alt="afosr_logo" width="150px" height="150px">
CMU Presidential FellowshipNational Science FoundationAir Force Office of Scientific Research
awarded to Emmanouil Antonios PlataniosGrant #: IIS1250956Grant #: FA95501710218

TensorFlow, the TensorFlow logo, and any related marks are trademarks of Google Inc.

<!--- ## Some TODOs - [ ] Figure out what the proper to way to handle Int vs Long shapes is, so that we can use Long shapes without hurting GPU performance. - [ ] Make the optimizers typed (with respect to their state, at least). - [ ] Make the gradients function retain types (we need a type trait for that). - [ ] Dispose dataset iterators automatically. - [ ] Fixed all `[TYPE] !!!` code TODOs. - [ ] Session execution context (I'm not sure if that's good to have) - [ ] Session reset functionality - [ ] Variables slicing - [ ] Slice assignment - [ ] Support for `CriticalSection`. - [ ] tfdbg / debugging support - [ ] tfprof / op statistics collection - Switch to using JUnit for all tests. - Add convenience implicit conversions for shapes (e.g., from tuples or sequences of integers). - Create a "Scope" class and companion object. - Variables API: - Clean up the implementation of variable scopes and stores and integrate it with "Scope". - Make 'PartitionedVariable' extend 'Variable'. - After that change, all 'getPartitionedVariable' methods can be integrated with the 'getVariable' methods, which will simplify the variables API. - Switch to using "Seq" instead of "Array" wherever possible. - Op creation: - Reset default graph - Register op statistics - Fix Travis CI support (somehow load the native library) - Website margins are a little large relative to the content in mobile - Make the code blocks scroll rather than wrap To publish a signed snapshot version of the package that is cross-compiled, we use the following commands from within an SBT shell: ```sbt set nativeCrossCompilationEnabled in jni := true publishSigned ``` You can also test cross-compilation using the following command: ```bash sbt jni/cross:nativeCrossCompile ``` CUDA Compute Capabilities: 3.5,7.0,7.5,8.0,8.6 Compile the TensorFlow dynamic libraries from source using: ```bash bazel build --config=opt --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 //tensorflow:libtensorflow.so ``` On Ubuntu 18.04 you may get some linking errors, in which case you should use: ```bash bazel build --config=opt --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 --noincompatible_do_not_split_linking_cmdline //tensorflow:libtensorflow.so ``` On Windows you may get some CUDA-related errors, in which case you should use: ```cmd bazel build --config=opt --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 --define=no_tensorflow_py_deps=true --copt=-DTHRUST_IGNORE_CUB_VERSION_CHECK --copt=-nvcc_options=disable-warnings //tensorflow:tensorflow.lib //tensorflow:tensorflow_framework.lib ``` For Mac we also need to deal with this currently: ```bash install_name_tool -id @rpath/libtensorflow.2.dylib libtensorflow.2.4.0.dylib install_name_tool -change @rpath/libtensorflow.so.2 @rpath/libtensorflow.2.dylib libtensorflow_framework.2.4.0.dylib ``` To publish the documentation website we use the following commands: ```bash sbt docs/previewSite # To preview the website sbt docs/ghpagesPushSite # To publish the website ``` To prepare the precompiled TensorFlow binary packages, use the following commands: ```bash mkdir lib cp -av /usr/local/lib/libtensorflow* lib/ tar -zcvf libtensorflow-2.2.0-cpu-darwin-x86_64.tar.gz lib tar -ztvf libtensorflow-2.2.0-cpu-darwin-x86_64.tar.gz ``` -->