All Projects → Octadero → TensorFlow

Octadero / TensorFlow

Licence: GPL-3.0 license
Swift high-level API for TensorFlow.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to TensorFlow

Tensorlayer Tricks
How to use TensorLayer
Stars: ✭ 357 (+628.57%)
Mutual labels:  tensorboard, tensorflow-models
Tensorflow-Wide-Deep-Local-Prediction
This project demonstrates how to run and save predictions locally using exported tensorflow estimator model
Stars: ✭ 28 (-42.86%)
Mutual labels:  tensorboard, tensorflow-models
kalker
Kalker/kalk is a calculator with math syntax that supports user-defined variables and functions, complex numbers, and estimation of derivatives and integrals
Stars: ✭ 1,237 (+2424.49%)
Mutual labels:  math
HLML
Auto-generated maths library for C and C++ based on HLSL/Cg
Stars: ✭ 23 (-53.06%)
Mutual labels:  math
Bitcamp-2019
Won the most innovative solution at Bitcamp 2019.🎖🎉
Stars: ✭ 15 (-69.39%)
Mutual labels:  tensorflow-models
EEG-Motor-Imagery-Classification-CNNs-TensorFlow
EEG Motor Imagery Tasks Classification (by Channels) via Convolutional Neural Networks (CNNs) based on TensorFlow
Stars: ✭ 125 (+155.1%)
Mutual labels:  tensorflow-models
mathcore
Advanced .NET math library (.NET Standard).
Stars: ✭ 24 (-51.02%)
Mutual labels:  math
livebook
Automate code & data workflows with interactive Elixir notebooks
Stars: ✭ 3,402 (+6842.86%)
Mutual labels:  math
Neural-Turing-Machine
TensorFlow implementation of a Neural Turing Machine
Stars: ✭ 23 (-53.06%)
Mutual labels:  tensorflow-models
Machine-Learning
🌎 I created this repository for educational purposes. It will host a number of projects as part of the process .
Stars: ✭ 38 (-22.45%)
Mutual labels:  tensorflow-models
TensorFlow-Multiclass-Image-Classification-using-CNN-s
Balanced Multiclass Image Classification with TensorFlow on Python.
Stars: ✭ 57 (+16.33%)
Mutual labels:  tensorflow-models
Portrait FCN and 3D Reconstruction
This project is to convert PortraitFCN+ (by Xiaoyong Shen) from Matlab to Tensorflow, then refine the outputs from it (converted to a trimap) using KNN and ResNet, supervised by Richard Berwick.
Stars: ✭ 61 (+24.49%)
Mutual labels:  tensorflow-models
zerolib-flixel
Some helper classes for HaxeFlixel that I like to use ✨
Stars: ✭ 28 (-42.86%)
Mutual labels:  math
python-baseconv
Python module to convert numbers from base 10 integers to base X strings and back again.
Stars: ✭ 40 (-18.37%)
Mutual labels:  math
Torch-Scope
A Toolkit for Training, Tracking, Saving Models and Syncing Results
Stars: ✭ 62 (+26.53%)
Mutual labels:  tensorboard
matrixgl
Yet another matrix library for WebGL
Stars: ✭ 25 (-48.98%)
Mutual labels:  math
TensorFlow-Binary-Image-Classification-using-CNN-s
Binary Image Classification in TensorFlow
Stars: ✭ 26 (-46.94%)
Mutual labels:  tensorflow-models
word-embeddings-from-scratch
Creating word embeddings from scratch and visualize them on TensorBoard. Using trained embeddings in Keras.
Stars: ✭ 22 (-55.1%)
Mutual labels:  tensorboard
DecFP.jl
Julia IEEE decimal floating-point via the Intel decimal-float library
Stars: ✭ 49 (+0%)
Mutual labels:  math
Fast-AgingGAN
A deep learning model to age faces in the wild, currently runs at 60+ fps on GPUs
Stars: ✭ 133 (+171.43%)
Mutual labels:  tensorboard

TensorFlow Swift high-level API. Tweet

Swift 4.0 Platforms Linux & OS X GPL Octadero Twitter

Structure of API

architecture

API based on TensorFlow library.

  • CTensorFlow is C API system module;
  • CAPI - Swift writen low-level API to C library;
  • Proto - Swift auto - generated classes for TensorFlow structures and models;
  • OpPruducer - Swift writen command line tool to produce new TensorFlow Operations
  • TensorFlowKit - Swift writen high-level API;

Using library.

First of all you should install tensorflow_c library. You can do that using brew on mac os. Version 1.4 currantly available for mac os and linux on Google cloud, so you can use it: Also, you can install it from sources, how to install TensorFlow from sources you can find here.

Tutorials

Xcode

Make shure that you read README of submodule CTensorFlow

To generate xcode project file you can call: If you install TensorFlow library (1.4.1 version) as brew package:

swift package -Xlinker -rpath -Xlinker /usr/local/Cellar/libtensorflow/1.4.1/lib/ generate-xcodeproj
swift package -Xlinker -rpath -Xlinker /server/repository/tensorflow/bazel-bin/tensorflow generate-xcodeproj

Where /server/repository/tensorflow/bazel-bin/tensorflow path to your TensorFlow C library /user/local/lib, usualy.

Also you can use config:

swift package generate-xcodeproj --xcconfig-overrides TensorFlow.xcconfig
  • At TensorFlow.xcconfig file set TENSORFLOW_PATH property with correct path.
  • It is important to set 'TensorFlow.xcconfig' name the same with projectfile.
  • There is issus SR-6073 with LD_RUNPATH_SEARCH_PATHS property. So, currently you have to set $(inherited) value manualy at your build variable.

Build and set RPATH setting:

#MacOS
swift build -Xlinker -rpath -Xlinker /usr/local/Cellar/libtensorflow/1.4.1/lib/
swift test -Xlinker -rpath -Xlinker /usr/local/Cellar/libtensorflow/1.4.1/lib/
#Linux
swift build -Xlinker -rpath -Xlinker /server/repository/tensorflow/bazel-bin/tensorflow
swift test -Xlinker -rpath -Xlinker /server/repository/tensorflow/bazel-bin/tensorflow

Features

Swift API provides accae to all available C features in TensorFlow library.

  • Create / read grapht;
  • Save statistic on file system;
  • Cunstruct and run session;
  • Include available operations;
  • Store and restore checkpoints by SavedModel class;

graph

Summary

Summary

Starting from version 0.0.5 you have posibility to track any metrics using TensorFlowKit. That is easy way to visualize your model in Swift application.

You can visualize weights and biases:

summary-distribution

Draw your graph:

summary-graph

Track changes in 3D:

summary-histogram

Extract components as png images:

summary-image

Watch on dynamics of changes:

summary-scalar

Troubleshooting

  • In case app can't load dynamic library on macOS:
otool -L libtensorflow_cc.so
sudo install_name_tool -id /%repository%/tensorflow/bazel-out/darwin_x86_64-opt/bin/tensorflow/libtensorflow_cc.so libtensorflow_cc.so
sudo install_name_tool -id /%repository%/tensorflow/bazel-out/darwin_x86_64-opt/bin/tensorflow/libtensorflow_framework.so libtensorflow_framework.so
sudo install_name_tool -id /%repository%/tensorflow/bazel-out/darwin_x86_64-opt/bin/tensorflow/libtensorflow.so libtensorflow.so
  • In case if app can't load dynamic library on linux or mac os with error:
error while loading shared libraries: *libtensorflow_cc.so*: cannot open shared object file: No such file or directory

Add your library path linux:

export LD_LIBRARY_PATH=/server/repository/tensorflow/bazel-bin/tensorflow:/usr/local/lib/:$LD_LIBRARY_PATH

mac os:

export DYLD_LIBRARY_PATH=/server/repository/tensorflow/bazel-bin/tensorflow/:$DYLD_LIBRARY_PATH

C++ old related issues.

  • At build phase error:
warning: error while trying to use pkgConfig flags for CProtobuf: nonWhitelistedFlags("Non whitelisted flags found: [\"-D_THREAD_SAFE\", \"-D_THREAD_SAFE\"] in pc file protobuf")

Remove -D_THREAD_SAFE keys from file /usr/local/lib/pkgconfig/protobuf.pc

Error at build phase:

#include "tensorflow/core/framework/graph.pb.h"                                                                                                                                         ^                                                                                                                                                                     1 error generated.                                                                                                                                                             error: terminated(1): /usr/bin/swift-build-tool -f /server/repository/TensorFlow/.build/debug.yaml main

Download dependencies for C++ library at tensorflow repository.

tensorflow/contrib/makefile/download_dependencies.sh

Developing and extending API

Create new proto files

// Create temperory folder
mkdir /tmp/swift
cd %path-to-tensorflow-reposytory%

// Find all proto files and generate swift classes.
find. -name '*.proto' -print -exec protoc --swift_opt=Visibility=Public --swift_out=/tmp/swift {} \;

// All files will be removed after restart.
open /tmp/swift

Debuging

Sets the threshold for what messages will be logged. Add TF_CPP_MIN_LOG_LEVEL=0 and TF_CPP_MIN_VLOG_LEVEL=0

List of operations

There are a few ways to get a list of the OpDefs for the registered ops:

TF_GetAllOpList in the C API retrieves all registered OpDef protocol messages. This can be used to write the generator in the client language. This requires that the client language have protocol buffer support in order to interpret the OpDef messages.

The C++ function OpRegistry::Global()->GetRegisteredOps() returns the same list of all registered OpDefs (defined in [tensorflow/core/framework/op.h]). This can be used to write the generator in C++ (particularly useful for languages that do not have protocol buffer support).

The ASCII-serialized version of that list is periodically checked in to [tensorflow/core/ops/ops.pbtxt] by an automated process.

OpProducer using C API to extract and prepare all available operation as Swift source code.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].