* * *

Author Topic: Pascal for TensorFlow  (Read 767 times)

Phil

  • Hero Member
  • *****
  • Posts: 2734
Pascal for TensorFlow
« on: June 23, 2018, 01:45:32 am »
New article on some first steps toward a Pascal for TensorFlow:

https://macpgmr.github.io

If you have any interest in machine learning, neural networks, matrix arithmetic, this article and downloadable code is for you.

Source is included for several Pascal example programs, from simple to complex. All have been tested against TensorFlow 1.8 on these platforms:

    macOS 10.11 El Capitan
    macOS 10.13 High Sierra
    Ubuntu 14.04

If you want to learn a bit about the things behind machine learning, you might take a look at Google's "crash course". The videos are quite short and easy digestible. Really. I was able to cruise through a half dozen before my brain fogged over.

https://developers.google.com/machine-learning/crash-course


Phil

  • Hero Member
  • *****
  • Posts: 2734
Re: Pascal for TensorFlow
« Reply #1 on: June 23, 2018, 02:15:31 pm »
Related article, possibly inspirational:

https://appleinsider.com/articles/18/06/06/this-third-year-wwdc-scholarship-winner-built-an-ml-model-to-recognize-beer-yesterday


Machine learning projects often fall into one of several areas: image classification (as in the beer app and the Pascal example MNIST program), natural language text classification, and more general stuff related to numerical categorization and estimation.


Phil

  • Hero Member
  • *****
  • Posts: 2734
Re: Pascal for TensorFlow
« Reply #2 on: July 16, 2018, 12:20:51 am »
I was curious about how well TensorFlow scales, so I timed some runs of the MNIST.pas image classification demo program. This program is not memory limited on systems with at least 4GB RAM and does not do any disk I/O within the training loop, so it should be a good example of a compute-bound program.

Note that MNIST.pas works with a 60000 x 784 input matrix (188 MB of memory).

On my old Late 2008 MacBook, MNIST took exactly 60 seconds to complete.

Next I tested MNIST on a 2017 MacBook. This is still a dual-core CPU, but a Core i7 which is clocked faster. It took 25 seconds, meaning a nice 2x bump as expected for a newer chip.

Finally I tested MNIST on an 8-core AWS instance running Ubuntu. In tests of other compute-bound models, this system has similar performance to the 2017 MacBook when utilizing only a single core. This system ran MNIST in only 12 seconds, suggesting that it was able to utilize more cores to do the arithmetic faster, without requiring any changes to the Pascal code.

Note that the TensorFlow library has a permissive Apache license. The Pascal for TensorFlow units are released under the same modified LGPL license as FPC RTL, meaning there shouldn't be many restrictions on your use of TensorFlow in any app you might write.

lainz

  • Hero Member
  • *****
  • Posts: 2779
  • I'm coding :)
    • Lainz
Re: Pascal for TensorFlow
« Reply #3 on: July 16, 2018, 02:23:00 am »
Thanks I'm interested. I need to find the time to try.

I once was on a live stream of Microsoft Latinoamérica but it was only - as I see it - a way to sell his own service of machine learning. It was too short and I get nothing with it.

Hope this is something I can afford and use.

Edit: oh this is free  :)
« Last Edit: July 16, 2018, 02:58:37 am by lainz »

Phil

  • Hero Member
  • *****
  • Posts: 2734
Re: Pascal for TensorFlow
« Reply #4 on: July 16, 2018, 02:39:20 pm »
Edit: oh this is free  :)

Yes, free and open source. I have only tested on macOS and Linux, but TensorFlow library is also available for Windows and Raspian. I've also tested on earlier versions of macOS and Ubuntu than what they give here:

https://www.tensorflow.org/install

The easiest way to obtain the TensorFlow library binaries on macOS and Linux is just to use the simple curl script given here:

https://www.tensorflow.org/install/install_c

Or just download the .gz directly. For example, for Linux or macOS with no GPU support:

https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.9.0.tar.gz

https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.9.0.tar.gz

And with all platforms, there are instructions for obtaining TensorFlow via Python's pip command, the assumption probably being that you'll use Python with TensorFlow (although we don't need Python at all with the Pascal interface).

One other way to get a copy of the TensorFlow binaries on macOS and Ubuntu is to install Swift for TensorFlow. I've tested that as well:

https://github.com/tensorflow/swift/blob/master/Installation.md


There's also TensorFlow Lite for mobile and embedded, although again I have not tested it:

https://www.tensorflow.org/mobile/tflite

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus