• Re: Artificial Intelligence libraries in ADA

    From Marius Amado-Alves@21:1/5 to All on Thu Nov 10 09:58:27 2022
    Resurrecting this 3-year old thread, see what happens:-)

    I too need AI and Machine Learning libraries, and I am literally disgusted at the prospective of having to use Python or Go or C++ for this. Has anything come up in the last 3 years? Maybe a binding to TensorFlow?

    I plan to use Carter's REM NN, and maybe Kasakov's fuzzy_ml, for some experiments, but at some point I'll want, like Bjorn Ludin, *recurrent* architectures, probably LSTM (Long Short* Term Memory), as I want to segment and classify text.

    (Jeff: can we somehow reenginer REM NN towards recurrency? Maybe by inserting recurrent layers?)

    *Not a typo. The ML geniuses really say "long short"...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey R.Carter@21:1/5 to Marius Amado-Alves on Thu Nov 10 20:10:00 2022
    On 2022-11-10 18:58, Marius Amado-Alves wrote:

    (Jeff: can we somehow reenginer REM NN towards recurrency? Maybe by inserting recurrent layers?)

    Probably best to discuss this off line. You can contact me by e-mail.

    --
    Jeff Carter
    "Hold your temper. Count ten.... Now let 'er go.
    You got a good aim."
    Never Give a Sucker an Even Break
    105

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luke A. Guest@21:1/5 to Jeffrey R.Carter on Thu Nov 10 19:18:10 2022
    On 10/11/2022 19:10, Jeffrey R.Carter wrote:
    On 2022-11-10 18:58, Marius Amado-Alves wrote:

    (Jeff: can we somehow reenginer REM NN towards recurrency? Maybe by
    inserting recurrent layers?)

    Probably best to discuss this off line. You can contact me by e-mail.


    Why?

    Also, Rod Kay (charlie on irc) did something re TF iirc.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Luke A. Guest on Fri Nov 11 21:20:04 2022
    On 11/11/22 06:18, Luke A. Guest wrote:

    Also, Rod Kay (charlie on irc) did something re TF iirc.


    I generated a thin binding to the TensorFlow C API via swig4ada
    around mid June. The binding has not been tested apart from a 'hello_TF'
    demo which simply calls the 'TF_Version' function and prints it.

    I've been distracted by other projects since but as chance would
    have it, I've recently resumed work on swig4ada and TF will definitely
    be one of the top priorities re testing swig4ada.

    I'll try to take another look at it this weekend and to get the TF
    binding onto github, if possible.


    Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dana B@21:1/5 to roda...@gmail.com on Sun Jan 8 08:32:52 2023
    On Friday, November 11, 2022 at 5:19:56 AM UTC-5, roda...@gmail.com wrote:
    On 11/11/22 06:18, Luke A. Guest wrote:

    Also, Rod Kay (charlie on irc) did something re TF iirc.
    I generated a thin binding to the TensorFlow C API via swig4ada
    around mid June. The binding has not been tested apart from a 'hello_TF'
    demo which simply calls the 'TF_Version' function and prints it.

    I've been distracted by other projects since but as chance would
    have it, I've recently resumed work on swig4ada and TF will definitely
    be one of the top priorities re testing swig4ada.

    I'll try to take another look at it this weekend and to get the TF
    binding onto github, if possible.


    Regards.

    Has this code been posted? I have been looking for some type of Ada binding to TensorFlow, and was coming up short. I'm green enough to not feel confident to just write it all myself, so I am digging around trying to find anything that might exist.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to Daniel on Sun Jan 8 17:56:49 2023
    On Wednesday, July 10, 2019 at 5:25:50 PM UTC+10, Daniel wrote:
    Does anybody knows pure Ada libraries for AI?

    Specially, I'm interested in Decission Trees, but I can't find anything on internet.

    I case of a negative answer, does anybody knows a good CPU perforamnce AI C/C++ Library working good binded to Ada code?

    I had a similar need involving TensorFlow.
    After much investigation I decided on the method suggested by

    http://www.inspirel.com/articles/Ada_Python_Demo.html
    This demo is rather simplistic and required some slight extension to be useful, mainly involving the passing of parameters to Python methods.

    I now have developed a fairly extensive, though probably far from complete, binding based on the inspirel method.
    An example of its use:
    Python.Initialize;
    MLP := Python.Import_File ("lesson_4cp");
    Python.Call (MLP, "classify", Train_X, Train_Y_1D, Test_X, Test_Y_1D);
    Python.Close_Module (MLP);
    Python.Finalize;

    where the Python.Call is to:
    procedure Call (M : Module; Function_Name : String;
    A : ML_Arrays_And_Matrices.Real_Float_Matrix;
    B : ML_Arrays_And_Matrices.Integer_Array;
    C : ML_Arrays_And_Matrices.Real_Float_Matrix;
    D : ML_Arrays_And_Matrices.Integer_Array);

    I decided on the inspirel method as it seems fairly straightforward and requires no 3rd party packages.
    It only involves the Python C Api interface, for example:
    function PyImport_Import (Obj : PyObject) return PyObject;
    pragma Import (C, PyImport_Import, "PyImport_Import");

    During my research I didn't come across many of the very interesting solutions mentioned in this conversation.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Dana B on Mon Jan 9 22:12:52 2023
    On 9/1/23 03:32, Dana B wrote:
    On Friday, November 11, 2022 at 5:19:56 AM UTC-5, roda...@gmail.com wrote:
    On 11/11/22 06:18, Luke A. Guest wrote:

    Also, Rod Kay (charlie on irc) did something re TF iirc.
    I generated a thin binding to the TensorFlow C API via swig4ada
    around mid June. The binding has not been tested apart from a 'hello_TF'
    demo which simply calls the 'TF_Version' function and prints it.

    I've been distracted by other projects since but as chance would
    have it, I've recently resumed work on swig4ada and TF will definitely
    be one of the top priorities re testing swig4ada.

    I'll try to take another look at it this weekend and to get the TF
    binding onto github, if possible.


    Regards.

    Has this code been posted? I have been looking for some type of Ada binding to TensorFlow, and was coming up short. I'm green enough to not feel confident to just write it all myself, so I am digging around trying to find anything that might exist.


    I'm sorry, I got distracted again (something about a crate :) ).

    I'll try to get the binding onto github tomorrow.


    Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From J-P. Rosen@21:1/5 to All on Mon Jan 9 11:49:24 2023
    Just for fun, I typed the subject ("Artificial Intelligence libraries in
    ADA") into https://chat.openai.com/chat. Here is the answer...

    --------------------------

    There are several libraries that offer artificial intelligence (AI) functionality in the Ada programming language. Here are a few examples:

    AI-Ada: This library provides various AI algorithms and data structures, including search algorithms, decision trees, and neural networks.

    Ada Neural Network Library (ANN): This library provides tools for
    creating and training artificial neural networks in Ada. It includes
    support for various types of networks and training algorithms.

    AdaBoost: This library provides an implementation of the AdaBoost
    (Adaptive Boosting) machine learning algorithm, which is used for classification tasks.

    AdaMILE: This library provides various machine learning algorithms for
    Ada, including support for decision trees, neural networks, and clustering.

    It's worth noting that these libraries may not be as feature-rich or well-maintained as some of the more popular AI libraries available in
    other programming languages. However, they can still be useful for
    certain projects or as a way to learn more about AI and machine learning.

    --
    J-P. Rosen
    Adalog
    2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
    https://www.adalog.fr https://www.adacontrol.fr

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dmitry A. Kazakov@21:1/5 to J-P. Rosen on Mon Jan 9 12:21:04 2023
    On 2023-01-09 11:49, J-P. Rosen wrote:

    It's worth noting that these libraries may not be as feature-rich or well-maintained as some of the more popular AI libraries available in
    other programming languages. However, they can still be useful for
    certain projects or as a way to learn more about AI and machine learning.

    I am always perplexed by such questions. A decision tree is not a method
    of machine learning, it is just a data structure.

    Depending on the type (crisp, probabilistic, fuzzy) a tree is quite easy
    to implement in Ada. And with any existing component library or else the standard Ada library, it is almost trivial.

    The crux is building such a tree from the samples so that the tree would classify the input, i.e. to learn from the training set. It puzzles me
    what people are expecting. Initial training and maybe reinforcement
    training are highly dependent on the problem at hand. There is no
    universal solution, otherwise it would not be AI. Depending on the
    training method specific tree operations are used such as rotations etc
    which require certain ways of tree representation especially if the
    problem size is massive. All this is very, very specific.

    The bottom line. Instead of looking for some miracles, just use Ada,
    which is an excellent language for AI (because AI requires performance
    and is almost impossible to debug).

    --
    Regards,
    Dmitry A. Kazakov
    http://www.dmitry-kazakov.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Dana B on Wed Jan 11 17:35:03 2023
    On 9/1/23 03:32, Dana B wrote:
    On Friday, November 11, 2022 at 5:19:56 AM UTC-5, roda...@gmail.com wrote:
    On 11/11/22 06:18, Luke A. Guest wrote:

    Also, Rod Kay (charlie on irc) did something re TF iirc.
    I generated a thin binding to the TensorFlow C API via swig4ada
    around mid June. The binding has not been tested apart from a 'hello_TF'
    demo which simply calls the 'TF_Version' function and prints it.

    I've been distracted by other projects since but as chance would
    have it, I've recently resumed work on swig4ada and TF will definitely
    be one of the top priorities re testing swig4ada.

    I'll try to take another look at it this weekend and to get the TF
    binding onto github, if possible.


    Regards.

    Has this code been posted? I have been looking for some type of Ada binding to TensorFlow, and was coming up short. I'm green enough to not feel confident to just write it all myself, so I am digging around trying to find anything that might exist.


    I've just added the binding today.

    https://github.com/charlie5/cBound/tree/master/tier-1/tensorflow

    Install instructions are in the top-level 'README.md'.

    Bear in mind the binding is auto generated, thin and is the C API
    version '2.11.0'.

    It's also auto-formatted using 'gnatpp' (for the Ada code) and 'indent'
    (for the C code).

    Other than the 'hello_tf' demo, it's also untested.

    I'll spend some time tomorrow cleaning up the formatting and removing
    some of the source code 'warts' (such as redundant 'with's).

    If you try it, please let me know how it goes (especially bugs :) ).


    Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to roda...@gmail.com on Wed Jan 11 18:46:18 2023
    On Wednesday, January 11, 2023 at 5:34:48 PM UTC+11, roda...@gmail.com wrote:
    On 9/1/23 03:32, Dana B wrote:
    On Friday, November 11, 2022 at 5:19:56 AM UTC-5, roda...@gmail.com wrote:
    On 11/11/22 06:18, Luke A. Guest wrote:

    Also, Rod Kay (charlie on irc) did something re TF iirc.
    I generated a thin binding to the TensorFlow C API via swig4ada
    around mid June. The binding has not been tested apart from a 'hello_TF' >> demo which simply calls the 'TF_Version' function and prints it.

    I've been distracted by other projects since but as chance would
    have it, I've recently resumed work on swig4ada and TF will definitely
    be one of the top priorities re testing swig4ada.

    I'll try to take another look at it this weekend and to get the TF
    binding onto github, if possible.



    I've just added the binding today.

    https://github.com/charlie5/cBound/tree/master/tier-1/tensorflow

    Install instructions are in the top-level 'README.md'.

    Bear in mind the binding is auto generated, thin and is the C API
    version '2.11.0'.

    It's also auto-formatted using 'gnatpp' (for the Ada code) and 'indent'
    (for the C code).

    Other than the 'hello_tf' demo, it's also untested.

    I'll spend some time tomorrow cleaning up the formatting and removing
    some of the source code 'warts' (such as redundant 'with's).

    If you try it, please let me know how it goes (especially bugs :) ).


    Regards.

    I've tried to install cBound and am not quite sure what I need to do.
    When I try to build the library it fails with:
    2023-01-12 13:37:54] /Ada_Source/cBound/tier-1/tensorflow/library/tensorflow.gpr:2:06: unknown project file: "swig"

    I have installed swig4ada but it does not seem to have a gpr file.

    Attempts to build the 'hello_tf' demo fails with: /Ada_Source/cBound/tier-1/tensorflow/applet/demo/hello_tf/hello_tf.gpr:2:06: unknown project file: "tensorflow"
    [2023-01-12 13:42:51] /Ada_Source/cBound/tier-1/tensorflow/applet/demo/hello_tf/hello_tf.gpr:3:06: unknown project file: "swig"

    Not surprising as I couldn't build the tensorflow library?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to roda...@gmail.com on Wed Jan 11 21:13:47 2023
    On Thursday, January 12, 2023 at 4:00:58 PM UTC+11, roda...@gmail.com wrote:
    On 12/1/23 13:46, Roger Mc wrote:
    On Wednesday, January 11, 2023 at 5:34:48 PM UTC+11, roda...@gmail.com wrote:

    I've tried to install cBound and am not quite sure what I need to do.
    When I try to build the library it fails with:
    2023-01-12 13:37:54] /Ada_Source/cBound/tier-1/tensorflow/library/tensorflow.gpr:2:06: unknown project file: "swig"

    I have installed swig4ada but it does not seem to have a gpr file.

    Attempts to build the 'hello_tf' demo fails with: /Ada_Source/cBound/tier-1/tensorflow/applet/demo/hello_tf/hello_tf.gpr:2:06: unknown project file: "tensorflow"
    [2023-01-12 13:42:51] /Ada_Source/cBound/tier-1/tensorflow/applet/demo/hello_tf/hello_tf.gpr:3:06: unknown project file: "swig"

    Not surprising as I couldn't build the tensorflow library?

    Have you followed the install instructions in the README.md ?



    Install

    Add the following lines to ~/.bashrc or equivalent ...

    export CBOUND=/path/to/cbound

    source $CBOUND/cbound-gpr_paths.sh



    That should make both 'swig.gpr' and 'tensorflow.gpr' visible to your app.

    I soon realised what was wrong and deleted this message; apparently not quickly enough.
    I did follow the instructions but then proceeded to operate from a non-updated terminal session!!!
    Anyway, thanks for your consideration.
    I’m now battling getting cBound to acces the tensorflow c_api on my Mac which I’ve definitely done before on other projects.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Roger Mc on Thu Jan 12 16:01:10 2023
    On 12/1/23 13:46, Roger Mc wrote:
    On Wednesday, January 11, 2023 at 5:34:48 PM UTC+11, roda...@gmail.com wrote:

    I've tried to install cBound and am not quite sure what I need to do.
    When I try to build the library it fails with:
    2023-01-12 13:37:54] /Ada_Source/cBound/tier-1/tensorflow/library/tensorflow.gpr:2:06: unknown project file: "swig"

    I have installed swig4ada but it does not seem to have a gpr file.

    Attempts to build the 'hello_tf' demo fails with: /Ada_Source/cBound/tier-1/tensorflow/applet/demo/hello_tf/hello_tf.gpr:2:06: unknown project file: "tensorflow"
    [2023-01-12 13:42:51] /Ada_Source/cBound/tier-1/tensorflow/applet/demo/hello_tf/hello_tf.gpr:3:06: unknown project file: "swig"

    Not surprising as I couldn't build the tensorflow library?

    Have you followed the install instructions in the README.md ?



    Install

    Add the following lines to ~/.bashrc or equivalent ...

    export CBOUND=/path/to/cbound

    source $CBOUND/cbound-gpr_paths.sh



    That should make both 'swig.gpr' and 'tensorflow.gpr' visible to your app.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to Roger Mc on Wed Jan 11 21:43:34 2023
    On Thursday, January 12, 2023 at 4:38:27 PM UTC+11, Roger Mc wrote:
    On Thursday, January 12, 2023 at 4:30:11 PM UTC+11, Roger Mc wrote:
    My problem now is that my hello_TF build fails in compiling tensorflow_wrap.c with:
    /Ada_Source/cBound/tier-1/tensorflow/source/thin/tensorflow_wrap.c:150:10: fatal error: tensorflow/tensorflow/c/c_api.h: No such file or directory
    150 | #include <tensorflow/tensorflow/c/c_api.h>

    As tensorflow_wrap.c was automatically generated by SWIG I'm not sure how to proceed.
    Certainly, there is no <tensorflow/tensorflow/c/c_api.h> on this computer.
    This problem also occurs when I attempt to build tier-1/tensorflow.

    I'm now cloning tensorflow from Git.
    Hopefully I'll be able to build it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to Roger Mc on Wed Jan 11 21:38:25 2023
    On Thursday, January 12, 2023 at 4:30:11 PM UTC+11, Roger Mc wrote:
    My problem now is that my hello_TF build fails in compiling tensorflow_wrap.c with:
    /Ada_Source/cBound/tier-1/tensorflow/source/thin/tensorflow_wrap.c:150:10: fatal error: tensorflow/tensorflow/c/c_api.h: No such file or directory
    150 | #include <tensorflow/tensorflow/c/c_api.h>

    As tensorflow_wrap.c was automatically generated by SWIG I'm not sure how to proceed.
    Certainly, there is no <tensorflow/tensorflow/c/c_api.h> on this computer.

    This problem also occurs when I attempt to build tier-1/tensorflow.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to All on Wed Jan 11 21:30:10 2023
    My problem now is that my hello_TF build fails in compiling tensorflow_wrap.c with:
    /Ada_Source/cBound/tier-1/tensorflow/source/thin/tensorflow_wrap.c:150:10: fatal error: tensorflow/tensorflow/c/c_api.h: No such file or directory
    150 | #include <tensorflow/tensorflow/c/c_api.h>

    As tensorflow_wrap.c was automatically generated by SWIG I'm not sure how to proceed.
    Certainly, there is no <tensorflow/tensorflow/c/c_api.h> on this computer.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Roger Mc on Thu Jan 12 18:31:28 2023
    On 12/1/23 16:43, Roger Mc wrote:
    On Thursday, January 12, 2023 at 4:38:27 PM UTC+11, Roger Mc wrote:
    On Thursday, January 12, 2023 at 4:30:11 PM UTC+11, Roger Mc wrote:
    My problem now is that my hello_TF build fails in compiling tensorflow_wrap.c with:
    /Ada_Source/cBound/tier-1/tensorflow/source/thin/tensorflow_wrap.c:150:10: fatal error: tensorflow/tensorflow/c/c_api.h: No such file or directory
    150 | #include <tensorflow/tensorflow/c/c_api.h>

    As tensorflow_wrap.c was automatically generated by SWIG I'm not sure how to proceed.
    Certainly, there is no <tensorflow/tensorflow/c/c_api.h> on this computer. >> This problem also occurs when I attempt to build tier-1/tensorflow.

    I'm now cloning tensorflow from Git.
    Hopefully I'll be able to build it.


    Does 'tensorflow/c/c_api.h' exist anywhere on your system ?

    If so, you might try modifying the 'tensorflow_wrap.c' #include to use
    your path to the 'c_api.h'.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Roger Mc on Thu Jan 12 19:02:08 2023
    On 12/1/23 16:43, Roger Mc wrote:
    On Thursday, January 12, 2023 at 4:38:27 PM UTC+11, Roger Mc wrote:
    On Thursday, January 12, 2023 at 4:30:11 PM UTC+11, Roger Mc wrote:
    My problem now is that my hello_TF build fails in compiling tensorflow_wrap.c with:
    /Ada_Source/cBound/tier-1/tensorflow/source/thin/tensorflow_wrap.c:150:10: fatal error: tensorflow/tensorflow/c/c_api.h: No such file or directory
    150 | #include <tensorflow/tensorflow/c/c_api.h>

    As tensorflow_wrap.c was automatically generated by SWIG I'm not sure how to proceed.
    Certainly, there is no <tensorflow/tensorflow/c/c_api.h> on this computer. >> This problem also occurs when I attempt to build tier-1/tensorflow.

    I'm now cloning tensorflow from Git.
    Hopefully I'll be able to build it.

    I've just updated the tensorflow binding (with formatting cosmetics) and
    pushed to github.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to roda...@gmail.com on Thu Jan 12 01:12:13 2023
    On Thursday, January 12, 2023 at 7:01:55 PM UTC+11, roda...@gmail.com wrote:

    I've just updated the tensorflow binding (with formatting cosmetics) and pushed to github.

    My build of the git cloned tensorflow failed.

    Does 'tensorflow/c/c_api.h' exist anywhere on your system ?
    If so, you might try modifying the 'tensorflow_wrap.c' #include to use your path to the 'c_api.h'.

    c_api.h exists in numerous places, particularly in the git cloned tensorflow just downloaded.
    It also exists deep in a couple of Python systems.
    As the git cloned tensorflow build failed, I think my best plan is to delete it as it consumes much disk space.
    I'll try using a path to one of the Python system versions.

    I've updated cBound to your latest push.
    Thanks for your assistance,
    Roger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to roda...@gmail.com on Thu Jan 12 02:51:55 2023
    On Thursday, January 12, 2023 at 9:32:23 PM UTC+11, roda...@gmail.com wrote:

    I doubt using a path to one of the Python system versions will work :/ .
    Yes, it fails due to c_api.h wanting to reference other tensorflow/c header files

    I've just succeeded building tier-1 tensorflow by
    1. modifying tier-1/tensorflow/library/tensorflow.gpr:
    for Source_Dirs use (".", "../source/**", "../../../../../Users/rogermcmurtrie/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/include");
    2. modifying tensorflow_wrap:
    #include <tensorflow/c/c_api.h>

    hello_TF compiles but link fails with:
    ld: library not found for -ltensorflow
    I think I should be able to fix this.


    Which OS are you using ?
    MacBook Air (13-inch, Early 2015). although purchased new from Apple in 2018! OSX restricted to version 10.13.6 High Sierra thanks to Apples planned obscelence policy.
    (although somewhat a blessing in disguise)
    GNAT Community 2021 (20210519)

    I also have a Mac_mini running OSX Ventura which has its own problems! However, I do have the latest GNAT working on it.
    If I can get this working on my MacBook Air I'll next try a Mac_mini Ventura version.
    I think tensorflow will build from source under Ventura.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Roger Mc on Thu Jan 12 21:32:37 2023
    On 12/1/23 20:12, Roger Mc wrote:
    On Thursday, January 12, 2023 at 7:01:55 PM UTC+11, roda...@gmail.com wrote:

    I've just updated the tensorflow binding (with formatting cosmetics) and
    pushed to github.

    My build of the git cloned tensorflow failed.

    Does 'tensorflow/c/c_api.h' exist anywhere on your system ?
    If so, you might try modifying the 'tensorflow_wrap.c' #include to use your path to the 'c_api.h'.

    c_api.h exists in numerous places, particularly in the git cloned tensorflow just downloaded.
    It also exists deep in a couple of Python systems.
    As the git cloned tensorflow build failed, I think my best plan is to delete it as it consumes much disk space.
    I'll try using a path to one of the Python system versions.

    I've updated cBound to your latest push.
    Thanks for your assistance,
    Roger

    I doubt using a path to one of the Python system versions will work :/ .

    Which OS are you using ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to All on Thu Jan 12 03:28:28 2023
    My hello_tf link is failing with:

    gprbuild -d -eL -P/Ada_Source/cBound/tier-1/tensorflow/applet/demo/hello_tf/hello_tf.gpr --config=/Ada_Source/default.cgpr -s
    Link
    [link] hello_tf.adb
    Undefined symbols for architecture x86_64:
    "_TF_AbortWhile", referenced from:
    _Ada_TF_AbortWhile in libTensorFlow.a(tensorflow_wrap.o)
    (maybe you meant: _Ada_TF_AbortWhile)
    etc.

    I have modified the hello_tf.gpr linker section to
    package Linker is
    for Default_Switches ("ada") use ("-Wl,-rpath,/usr/local/lib", "-L/Users/rogermcmurtrie/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow", "-ltensorflow_framework",
    "-L/Ada_Source/cBound/tier-1/tensorflow/library/lib", "-lTensorFlow");
    end Linker;

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Roger Mc on Thu Jan 12 23:18:54 2023
    On 12/1/23 22:28, Roger Mc wrote:
    My hello_tf link is failing with:

    gprbuild -d -eL -P/Ada_Source/cBound/tier-1/tensorflow/applet/demo/hello_tf/hello_tf.gpr --config=/Ada_Source/default.cgpr -s
    Link
    [link] hello_tf.adb
    Undefined symbols for architecture x86_64:
    "_TF_AbortWhile", referenced from:
    _Ada_TF_AbortWhile in libTensorFlow.a(tensorflow_wrap.o)
    (maybe you meant: _Ada_TF_AbortWhile)
    etc.


    Hmm, by 'etc' do you mean there are many more undefined symbols ? If so,
    could you pastebin the entire output of the gprbuild command


    I have modified the hello_tf.gpr linker section to
    package Linker is
    for Default_Switches ("ada") use ("-Wl,-rpath,/usr/local/lib", "-L/Users/rogermcmurtrie/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow", "-ltensorflow_framework",
    "-L/Ada_Source/cBound/tier-1/tensorflow/library/lib", "-lTensorFlow");
    end Linker;


    Maybe try adding "-ltensorflow" to the Linker 'Default_Switches', just
    after the "-ltensorflow_framework" switch.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to roda...@gmail.com on Thu Jan 12 14:09:55 2023
    On Thursday, January 12, 2023 at 11:18:42 PM UTC+11, roda...@gmail.com wrote:
    On 12/1/23 22:28, Roger Mc wrote:

    I have modified the hello_tf.gpr linker section to
    package Linker is
    for Default_Switches ("ada") use ("-Wl,-rpath,/usr/local/lib", "-L/Users/rogermcmurtrie/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow", "-ltensorflow_framework",
    "-L/Ada_Source/cBound/tier-1/tensorflow/library/lib", "-lTensorFlow");
    end Linker;
    Maybe try adding "-ltensorflow" to the Linker 'Default_Switches', just
    after the "-ltensorflow_framework" switch.

    Adding "-ltensorflow" didn't work as my tensorflow installation doesn't have any libtensorflow libraries.

    I tried installing a new version of tensor flow via pip install tensorflow and checked that it had installed correctly as described by the installation instructions.
    The new version still only contains the following libraries libtensorflow_framework.2.6.5.dylib
    libtensorflow_framework.2.dylib
    libtensorflow_framework.dylib

    Today, I'll try getting hello_tf to work on my Ventura machine using a brew installation of tensorflow.
    Brew installation of tensorflow under High Sierra fails.
    Regards,
    Roger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to Roger Mc on Thu Jan 12 16:12:23 2023
    On Friday, January 13, 2023 at 9:09:57 AM UTC+11, Roger Mc wrote:
    Today, I'll try getting hello_tf to work on my Ventura machine using a brew installation of tensorflow.

    Good news!
    hello_tf works under my OSX Ventura after a bit of adjustment.

    I didn't need to change the linker settings.
    Tensorflow installed by Brew includes
    libtensorflow_framework.dylib and
    libtensorflow.so

    -ltensorflow presumably linked to libtensorflow.so
    A bit strange as I thought that Apple had deprecated so files long ago.

    Regards,
    Roger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to Roger Mc on Thu Jan 12 16:40:46 2023
    On Friday, January 13, 2023 at 11:12:25 AM UTC+11, Roger Mc wrote:
    On Friday, January 13, 2023 at 9:09:57 AM UTC+11, Roger Mc wrote:
    Today, I'll try getting hello_tf to work on my Ventura machine using a brew installation of tensorflow.
    Good news!
    hello_tf works under my OSX Ventura after a bit of adjustment.

    All I need now is a few clues on how to use the bindings.
    For example, how to implement:
    mnist = tf.keras.datasets.mnist

    Regards,
    Roger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Roger Mc on Fri Jan 13 18:24:06 2023
    On 13/1/23 11:40, Roger Mc wrote:
    On Friday, January 13, 2023 at 11:12:25 AM UTC+11, Roger Mc wrote:

    All I need now is a few clues on how to use the bindings.
    For example, how to implement:
    mnist = tf.keras.datasets.mnist


    Yes, indeed. I was unable to find any demo's or examples which use the
    TF C API. If you find any please let me know ?

    Also, I am on the #ada IRC channel at 'irc.libera.chat'. Would be great
    if you could join and discuss TF in Ada there (my nick is charlie5).


    Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Roger Mc on Fri Jan 13 18:19:13 2023
    On 13/1/23 11:12, Roger Mc wrote:
    On Friday, January 13, 2023 at 9:09:57 AM UTC+11, Roger Mc wrote:
    Today, I'll try getting hello_tf to work on my Ventura machine using a brew installation of tensorflow.

    Good news!
    hello_tf works under my OSX Ventura after a bit of adjustment.


    Good news indeed :) .

    I didn't need to change the linker settings.
    Tensorflow installed by Brew includes
    libtensorflow_framework.dylib and
    libtensorflow.so

    Would you able to send me a patch file for the bits which did need
    adjusting, so I can add it to the cBound repo ?


    -ltensorflow presumably linked to libtensorflow.so
    A bit strange as I thought that Apple had deprecated so files long ago.

    I'm afraid I don't know anything about Apple or MacOS except a vague
    notion that it was based on one of the BSD's ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marius Amado-Alves@21:1/5 to All on Fri Jan 13 03:18:28 2023
    For example, how to implement:
    mnist = tf.keras.datasets.mnist
    (Roger)

    Isn't Keras Python?
    (If you're going to use Python, why use Ada?)
    [The MNIST data is available independently of any language (http://yann.lecun.com/exdb/mnist/)]
    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to amado...@gmail.com on Fri Jan 13 06:55:55 2023
    On Friday, January 13, 2023 at 10:18:29 PM UTC+11, amado...@gmail.com wrote:
    For example, how to implement:
    mnist = tf.keras.datasets.mnist
    (Roger)

    Isn't Keras Python?
    Yes.
    (If you're going to use Python, why use Ada?)
    The objective is to provide an example of the use of cBound in providing an interface between Tensorflow (Python) and Ada.
    The idea of this example is simply (?) to use an existing Tensorflow function to read data into an Ada program for processing by the Ada program.
    Why use Ada?
    Some of us prefer to program in Ada rather than in Python.
    [The MNIST data is available independently of any language (http://yann.lecun.com/exdb/mnist/)]
    True.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to roda...@gmail.com on Fri Jan 13 14:13:41 2023
    On Friday, January 13, 2023 at 6:23:51 PM UTC+11, roda...@gmail.com wrote:
    On 13/1/23 11:40, Roger Mc wrote:
    On Friday, January 13, 2023 at 11:12:25 AM UTC+11, Roger Mc wrote:

    All I need now is a few clues on how to use the bindings.
    For example, how to implement:
    mnist = tf.keras.datasets.mnist

    Yes, indeed. I was unable to find any demo's or examples which use the
    TF C API. If you find any please let me know ?
    Certainly.
    My current intention is to develop an example of my own but it might take some time.
    I intend to start by using my current methods then adapt the result yo use cBound.
    Not particularly confident at this stage!

    Also, I am on the #ada IRC channel at 'irc.libera.chat'. Would be great
    if you could join and discuss TF in Ada there (my nick is charlie5).
    I'll check it out.

    Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to roda...@gmail.com on Fri Jan 13 14:08:43 2023
    On Friday, January 13, 2023 at 6:18:58 PM UTC+11, roda...@gmail.com wrote:
    Would you able to send me a patch file for the bits which did need
    adjusting, so I can add it to the cBound repo ?

    Probably easier if I just report changes that I found necessary to get it to work.
    A patch file would probably include stuff specific to my own installation and formatting preferences.
    1. I removed "-lpthread" from Builder sections of the project (gpr) files due to builder complaint.
    2. In tensorflow_wrap.c I needed to change
    #include <tensorflow/tensorflow/c/c_api.h>
    to
    #include <tensorflow/c/c_api.h>
    3. In tensorflow.gpr I needed to change
    with "swig";
    to
    with "../../../tier-0/swig/library/swig.gpr";
    4. In tensorflow.gpr I added my path to tensorflow/c/c_api.h to the Source_Dirs In my case: "/usr/local/Cellar/libtensorflow/2.11.0/include"
    5. Not sure whether or not I caused this diff statement for the gpr files:
    -end hello_TF;
    \ No newline at end of file
    +end Hello_TF;
    6. In hello_tf.gpr:
    -with
    - "tensorflow",
    - "swig";
    +with "../../../library/tensorflow.gpr";
    Presumably with is "swig" redundant as imported by tensorflow.gpr

    I'm afraid I don't know anything about Apple or MacOS except a vague
    notion that it was based on one of the BSD's ?
    Yes, MacOS is a Unix derivative and can be interacted with using standard Unix commands.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to Roger Mc on Sat Jan 14 20:35:07 2023
    On 14/1/23 09:08, Roger Mc wrote:
    On Friday, January 13, 2023 at 6:18:58 PM UTC+11, roda...@gmail.com wrote:
    Would you able to send me a patch file for the bits which did need
    adjusting, so I can add it to the cBound repo ?

    Probably easier if I just report changes that I found necessary to get it to work.
    A patch file would probably include stuff specific to my own installation and formatting preferences.
    1. I removed "-lpthread" from Builder sections of the project (gpr) files due to builder complaint.
    2. In tensorflow_wrap.c I needed to change
    #include <tensorflow/tensorflow/c/c_api.h>
    to
    #include <tensorflow/c/c_api.h>
    3. In tensorflow.gpr I needed to change
    with "swig";
    to
    with "../../../tier-0/swig/library/swig.gpr";
    4. In tensorflow.gpr I added my path to tensorflow/c/c_api.h to the Source_Dirs
    In my case: "/usr/local/Cellar/libtensorflow/2.11.0/include"
    5. Not sure whether or not I caused this diff statement for the gpr files: -end hello_TF;
    \ No newline at end of file
    +end Hello_TF;
    6. In hello_tf.gpr:
    -with
    - "tensorflow",
    - "swig";
    +with "../../../library/tensorflow.gpr";
    Presumably with is "swig" redundant as imported by tensorflow.gpr


    Thanks.


    I've opened an issue for these problems in the github cBound repo ...

    https://github.com/charlie5/cBound/issues/2


    Perhaps we can continue there. This thread is getting a bit *big* :) .

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Mc@21:1/5 to roda...@gmail.com on Sat Jan 14 03:53:02 2023
    On Saturday, January 14, 2023 at 8:34:53 PM UTC+11, roda...@gmail.com wrote:
    On 14/1/23 09:08, Roger Mc wrote:
    On Friday, January 13, 2023 at 6:18:58 PM UTC+11, roda...@gmail.com wrote:
    Would you able to send me a patch file for the bits which did need
    adjusting, so I can add it to the cBound repo ?

    Probably easier if I just report changes that I found necessary to get it to work.
    A patch file would probably include stuff specific to my own installation and formatting preferences.
    1. I removed "-lpthread" from Builder sections of the project (gpr) files due to builder complaint.
    2. In tensorflow_wrap.c I needed to change
    #include <tensorflow/tensorflow/c/c_api.h>
    to
    #include <tensorflow/c/c_api.h>
    3. In tensorflow.gpr I needed to change
    with "swig";
    to
    with "../../../tier-0/swig/library/swig.gpr";
    4. In tensorflow.gpr I added my path to tensorflow/c/c_api.h to the Source_Dirs
    In my case: "/usr/local/Cellar/libtensorflow/2.11.0/include"
    5. Not sure whether or not I caused this diff statement for the gpr files: -end hello_TF;
    \ No newline at end of file
    +end Hello_TF;
    6. In hello_tf.gpr:
    -with
    - "tensorflow",
    - "swig";
    +with "../../../library/tensorflow.gpr";
    Presumably with is "swig" redundant as imported by tensorflow.gpr

    Thanks.


    I've opened an issue for these problems in the github cBound repo ...

    https://github.com/charlie5/cBound/issues/2


    Perhaps we can continue there. This thread is getting a bit *big* :) .

    Agreed.
    I'll recheck Problem 3

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)