tensorflow_scala

所属分类:数值算法/人工智能
开发工具:Scala
文件大小:2566KB
下载次数:0
上传日期:2022-06-22 21:53:34
上 传 者sh-1993
说明:  tensorflow_scala,用于scala编程语言的tensorflow API
(tensorflow_scala,TensorFlow API for the Scala Programming Language)

文件列表:
.circleci (0, 2022-06-23)
.circleci\config.yml (1533, 2022-06-23)
.circleci\images (0, 2022-06-23)
.circleci\images\Dockerfile.linux-cpu-x86_64 (260, 2022-06-23)
.circleci\images\Dockerfile.linux-gpu-x86_64 (737, 2022-06-23)
.circleci\images\docker_build_linux-cpu-x86_64.sh (356, 2022-06-23)
.circleci\images\docker_build_linux-gpu-x86_64.sh (356, 2022-06-23)
.circleci\images\install.sh (2300, 2022-06-23)
.jvmopts (125, 2022-06-23)
.scalafmt.conf (4035, 2022-06-23)
LICENSE (11434, 2022-06-23)
RELEASE.md (9635, 2022-06-23)
build.sbt (17518, 2022-06-23)
docs (0, 2022-06-23)
docs\images (0, 2022-06-23)
docs\images\logo.afdesign (7758177, 2022-06-23)
docs\images\logo.pdf (47432, 2022-06-23)
docs\images\logo.png (27480, 2022-06-23)
docs\images\logo.svg (56935, 2022-06-23)
docs\images\logo_square.afdesign (23905, 2022-06-23)
docs\images\logo_square.png (14605, 2022-06-23)
docs\src (0, 2022-06-23)
docs\src\main (0, 2022-06-23)
docs\src\main\paradox (0, 2022-06-23)
docs\src\main\paradox\assets (0, 2022-06-23)
docs\src\main\paradox\assets\custom.css (9237, 2022-06-23)
docs\src\main\paradox\assets\images (0, 2022-06-23)
docs\src\main\paradox\assets\images\afosr_logo.gif (249901, 2022-06-23)
docs\src\main\paradox\assets\images\cmu_logo.svg (14052, 2022-06-23)
docs\src\main\paradox\assets\images\favicon.ico (14605, 2022-06-23)
docs\src\main\paradox\assets\images\logo.png (14605, 2022-06-23)
docs\src\main\paradox\assets\images\nsf_logo.svg (199059, 2022-06-23)
docs\src\main\paradox\assets\images\tensorboard_mnist_example_plot.png (136823, 2022-06-23)
docs\src\main\paradox\assets\images\tensorflow_logo.png (14851, 2022-06-23)
docs\src\main\paradox\assets\images\tensorflow_logo_square.svg (2013, 2022-06-23)
docs\src\main\paradox\assets\images\tensorflow_logo_wide.svg (6900, 2022-06-23)
... ...


----------------- [![CircleCI](https://img.shields.io/circleci/project/github/eaplatanios/tensorflow_scala.svg?style=flat-square)](https://circleci.com/gh/eaplatanios/tensorflow_scala/tree/master) [![Codacy Badge](https://img.shields.io/codacy/grade/7fae7fba84df4831a80bc20c3bd021df.svg?style=flat-square)](https://www.codacy.com/app/eaplatanios/tensorflow_scala?utm_source=github.com&utm_medium=referral&utm_content=eaplatanios/tensorflow_scala&utm_campaign=Badge_Grade) ![License](https://img.shields.io/github/license/eaplatanios/tensorflow_scala.svg?style=flat-square) [![API Docs](https://img.shields.io/badge/docs-api-lightgrey.svg?longCache=true&style=flat-square&logo=read-the-docs&logoColor=white)](http://platanios.org/tensorflow_scala/api/api) [![JNI Docs](https://img.shields.io/badge/docs-jni-lightgrey.svg?longCache=true&style=flat-square&logo=read-the-docs&logoColor=white)](http://platanios.org/tensorflow_scala/api/jni) [![Data Docs](https://img.shields.io/badge/docs-data-lightgrey.svg?longCache=true&style=flat-square&logo=read-the-docs&logoColor=white)](http://platanios.org/tensorflow_scala/api/data) [![Examples Docs](https://img.shields.io/badge/docs-examples-lightgrey.svg?longCache=true&style=flat-square&logo=read-the-docs&logoColor=white)](http://platanios.org/tensorflow_scala/api/examples) This library is a Scala API for [https://www.tensorflow.org](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](https://img.shields.io/badge/chat-gitter-ed1965.svg?longCache=true&style=flat-square&logo=gitter)](https://gitter.im/eaplatanios/tensorflow_scala?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Please refer to the main website for documentation and tutorials. Here are a few useful links: - [Installation](https://eaplatanios.github.io/tensorflow_scala/installation.html) - [Getting Started Guide](https://eaplatanios.github.io/tensorflow_scala/getting_started.html) - [Library Architecture](https://eaplatanios.github.io/tensorflow_scala/architecture.html) - [Contributing](https://eaplatanios.github.io/tensorflow_scala/contributing.html) ## 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: ```bibtex @misc{Platanios:2018:tensorflow-scala, title = {{TensorFlow Scala}}, author = {Platanios, Emmanouil Antonios}, howpublished = {\url{https://github.com/eaplatanios/tensorflow_scala}}, year = {2018} } ``` ## Main Features - Easy manipulation of tensors and computations involving tensors (similar to NumPy in Python): ```scala val t1 = Tensor(1.2, 4.5) val t2 = Tensor(-0.2, 1.1) t1 + t2 == Tensor(1.0, 5.6) ``` - Low-level graph construction API, similar to that of the Python API, but strongly typed wherever possible: ```scala val inputs = tf.placeholder[Float](Shape(-1, 10)) val outputs = tf.placeholder[Float](Shape(-1, 10)) val predictions = tf.nameScope("Linear") { val weights = tf.variable[Float]("weights", Shape(10, 1), tf.ZerosInitializer) tf.matmul(inputs, weights) } val loss = tf.sum(tf.square(predictions - outputs)) val optimizer = tf.train.AdaGrad(1.0f) val trainOp = optimizer.minimize(loss) ``` - Numpy-like indexing/slicing for tensors. For example: ```scala tensor(2 :: 5, ---, 1) // is equivalent to numpy's 'tensor[2:5, ..., 1]' ``` - High-level API for creating, training, and using neural networks. For example, the following code shows how simple it is to train a multi-layer perceptron for MNIST using TensorFlow for Scala. Here we omit a lot of very powerful features such as summary and checkpoint savers, for simplicity, but these are also very simple to use. ```scala // Load and batch data using pre-fetching. val dataset = MNISTLoader.load(Paths.get("/tmp")) val trainImages = tf.data.datasetFromTensorSlices(dataset.trainImages.toFloat) val trainLabels = tf.data.datasetFromTensorSlices(dataset.trainLabels.toLong) val trainData = trainImages.zip(trainLabels) .repeat() .shuffle(10000) .batch(256) .prefetch(10) // Create the MLP model. val input = Input(FLOAT32, Shape(-1, 28, 28)) val trainInput = Input(INT***, Shape(-1)) val layer = Flatten[Float]("Input/Flatten") >> Linear[Float]("Layer_0", 128) >> ReLU[Float]("Layer_0/Activation", 0.1f) >> Linear[Float]("Layer_1", ***) >> ReLU[Float]("Layer_1/Activation", 0.1f) >> Linear[Float]("Layer_2", 32) >> ReLU[Float]("Layer_2/Activation", 0.1f) >> Linear[Float]("OutputLayer", 10) val loss = SparseSoftmaxCrossEntropy[Float, Long, Float]("Loss") >> Mean("Loss/Mean") val optimizer = tf.train.GradientDescent(1e-6f) val model = Model.simpleSupervised(input, trainInput, layer, loss, optimizer) // Create an estimator and train the model. val estimator = InMemoryEstimator(model) estimator.train(() => trainData, StopCriteria(maxSteps = Some(1000000))) ``` And by changing a few lines to the following code, you can get checkpoint capability, summaries, and seamless integration with TensorBoard: ```scala val loss = SparseSoftmaxCrossEntropy[Float, Long, Float]("Loss") >> Mean("Loss/Mean") >> ScalarSummary(name = "Loss", tag = "Loss") val summariesDir = Paths.get("/tmp/summaries") val estimator = InMemoryEstimator( modelFunction = model, configurationBase = Configuration(Some(summariesDir)), trainHooks = Set( SummarySaver(summariesDir, StepHookTrigger(100)), CheckpointSaver(summariesDir, StepHookTrigger(1000))), tensorBoardConfig = TensorBoardConfig(summariesDir)) estimator.train(() => trainData, StopCriteria(maxSteps = Some(100000))) ``` If you now browse to `https://127.0.0.1:6006` while training, you can see the training progress: tensorboard_mnist_example_plot - Efficient interaction with the native library that avoids unnecessary copying of data. All tensors are created and managed by the native TensorFlow library. When they are passed to the Scala API (e.g., fetched from a TensorFlow session), we use a combination of weak references and a disposing thread running in the background. Please refer to `tensorflow/src/main/scala/org/platanios/tensorflow/api/utilities/Disposer.scala`, for the implementation. ## 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 - [Object Detection using Pre-Trained Models](https://brunk.io/deep-learning-in-scala-part-3-object-detection.html) ## Funding Funding for the development of this library has been generously provided by the following sponsors: |cmu_logo|nsf_logo|afosr_logo| |:---------------------------------------:|:---------------------------------:|:-----------------------------------------------:| | **CMU Presidential Fellowship** | **National Science Foundation** | **Air Force Office of Scientific Research** | | awarded to Emmanouil Antonios Platanios | Grant #: IIS1250956 | Grant #: FA95501710218 | TensorFlow, the TensorFlow logo, and any related marks are trademarks of Google Inc.

近期下载者

相关文件


收藏者