A single neuron in Bash script

  • 2 Replies
  • 97 Views
*

Dat D

  • Bumblebee
  • **
  • 42
  • 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

  • Trusty Member
  • *********
  • Terminator
  • *
  • 765
  • 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: [Select]
dc -e '2 k 12.34 34.12 + p'
46.46

*

Dat D

  • Bumblebee
  • **
  • 42
  • 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: [Select]
dc -e '2 k 12.34 34.12 + p'
46.46
yeah, that dc is faster, tks.


infix, postfix, prefix are all ok :)

 


Users Online

11 Guests, 1 User
Users active in past 15 minutes:
WriterOfMinds
[Trusty Member]

Most Online Today: 28. Most Online Ever: 340 (March 26, 2019, 09:47:57 PM)

Articles