A single neuron in Bash script

  • 2 Replies
  • 608 Views
*

Dat D

  • Nomad
  • ***
  • 92
  • AI rocks!
A single neuron in Bash script
« on: February 20, 2020, 03:39:37 am »

I created this single neuron in Bash, lots of fun with this ML in Bash; so funny.  :2funny:


Bash doesn't do floating-point calculation so I needed help from Perl, the rest is Bash script.


It is super slow, Perl function calls are in Lisp style and each math op is done with creating a new Perl process.


Colab link: https://colab.research.google.com/drive/1KRjliLlp_zccfzcyFjFE2qWezRKWsOgo

*

infurl

  • Administrator
  • ***********
  • Eve
  • *
  • 1301
  • Humans will disappoint you.
    • Home Page
Re: A single neuron in Bash script
« Reply #1 on: February 20, 2020, 04:05:23 am »
Haha it sounds like you have too much time on your hands. :D

The usual method of performing calculations on the command line "expr" doesn't support floating point, that's true, but you could probably get better performance if you used "dc" instead, unless you really don't like reverse polish notation.
Code
dc -e '2 k 12.34 34.12 + p'
46.46

*

Dat D

  • Nomad
  • ***
  • 92
  • AI rocks!
Re: A single neuron in Bash script
« Reply #2 on: February 20, 2020, 05:35:48 am »
Haha it sounds like you have too much time on your hands. :D

The usual method of performing calculations on the command line "expr" doesn't support floating point, that's true, but you could probably get better performance if you used "dc" instead, unless you really don't like reverse polish notation.
Code
dc -e '2 k 12.34 34.12 + p'
46.46
yeah, that dc is faster, tks.


infix, postfix, prefix are all ok :)