Search

Geek Girl Joy

Artificial Intelligence, Simulations & Software

Tag

Pathfinder

Pathfinder – The Rodízio Contingency

Over the centuries and throughout my travels I’ve come to rely on my compass and a good map to point me in the right direction for my next adventure.

Sometimes my adventure led me to treasures in mysteriously exotic & remote locations, while other times I found myself among friendly and awfully generous cannibals who wanted to invite me to dinner… of course, it’s always best to politely decline such invitations because if anything I certainly live by the rule:

“If I’m on the carte du jour as flambé, I’ll skip the buffet and run away because I’m no entrée!”
~GeekGirlJoy

Hmmm, come to think of it, that might be the best piece advice I’ve ever given on this blog and if you agree consider supporting me through Patreon! 😉

In any case, despite the occasional fears I’ve held over the last few millennia over potentially becoming someones late-night heartburn, I’ve kinda always known that no matter how bad things got while exploring, I’d be okay because beyond a good compass and a fragmented (then taped back together) map with a sweet X scrawled in blood somewhere on it… I possess a secret tool that all the great explorers down through the ages have relied upon and today, I’m going to share it with you!

But… before I do, here’s today’s wallpaper!

The Rodízio Contingency Wallpaper
The Rodízio Contingency Wallpaper

The Pathfinder

From Allan Quatermain to Amerigo Vespucci, Erik the Red to Captain Nemo and even Jill of the Jungle… all notable explorers have relied on an enchanted automaton totem called “Pathfinder Stones”.

The stones are first consecrated with the live blood of a dead turnip and when brought into close proximity of their owner and a target on a map, will glow to show a path from where you are to where your desired destination is.

Which does bring us to the topic of today… I transmuted one of my sets of pathfinder stones into a digital form using the uh… “Quantum FANN Effect” and an ancient shadow daemon called JavaScript.

Schtick Aside

Okay, so what I did was use the JavaScript version of FANN to deploy an implementation of my original Pathfinder on GitHub pages.

The cool/interesting thing about FANN.js is that it uses asm.js to make the compiled FANN library available inside a web browser.

What this means is that a working version of Pathfinder is now online for you to play with (link blow) however…

There are two fairly large downsides to deploying with FANN.js instead of PHP-FANN:

  1. You cannot save the ANN after training.
  2. You cannot load a previously trained ANN.

These limitations mean that Pathfinder must be trained once every time the page loads and this does limit the size and complexity of ANN’s that are deployable using FANN.js.

The thing is it may still be possible to save the ANN by using the supported FANN lib methods/functions like I did when I built the FANN-Neural-Network-Visualizer to manually query the ANN object and then format/export the necessary information as a string/plain text because the FANN ANN.net save file format seemingly isn’t all that different from an .INI file (though I am uncertain if this is universal in all language implementations of FANN) and it’s something I plan on playing around with in the future.

Far be it for me to be the barer of fake news… turns out… it actually helps to read the documentation thoroughly and not just skim it and then do a search for keywords! 😛

FANN.js actually DOES have a save function but it doesn’t follow the FANN Lib reference manual of “save_…” convention and instead implements a JS Object.export().

I understand why they did that… and it does kinda make sense in the mixed up JS world but… it still holds to my “anti-wheel” digression argument that you haven’t read about yet.

Having said that… I promise to ritually self-flagellate by Gothic torch light using the sharp side of a motherboard!

I really should have done a better job of reading the docs! :-/

Why use FANN.js over PHP-FANN

Far be it for me to ever sing the praises of JS over PHP however in order to deply a neural network using PHP you have to have a server and the ability to compile & install PHP extensions and that costs money whereas GitHub Pages is free to me and to you but it doesn’t support the more robust server architecture that PHP requires so using FANN.js allows me to deploy my bots and AI in a way that let’s you actually use them instead of just reading about them.

All things being equal, I would still recommend the PHP version of FANN however the JS version does work and with a little improvement could become a viable deployment option!

Having said that, what I am really interested in with FANN.js is that JavaScript has a direct path between the browser environment via the WebGL API to the GPU whereas with PHP it is technically possible to commune with the GPU, however in practice it’s not generally done and until the PHP dev’s get their head out of their asses and start thinking out side the box (PHP is now mostly a general purposes language so start treating it like one…), PHP+GPU stuffs isn’t going to be the easiest pickle jar to crack using PHP and the existing available options though again, I’m not saying it is impossible either.

So, in the future I intend to see if I can’t use FANN.js + WebGL shaders to make FANN training faster (no promises) and then hopefully export the ANN.net file so that we can use/deploy the GPU trained ANN in a PHP environment.

Play Stump the Neural Network

So the online version of the Pathfinder network learns/re-trains from scratch every time the page loads and as such it can’t spend unlimited amounts of time training which is normally not a concern because even if your 1000 layer celebrity deep fake porn ANN takes 100 CPU years to train (i.e. 1 CPU = 100 years, 100 CPU = 1 year etc… ) it isn’t a major concern because likely you are buying your compute from Jeff Bezos or Bill Gates and they have plenty of underutilized computers laying around waiting for you to rent a few FLOPS.

In the end, you save the ANN model so you can use it immediately when you want it… but FANN.js says “Nah I’m good! Who needs to do something as convenient as save or reload!” (then again (and mostly off topic) JavaScript tends to seem to like reinventing round wheels as square uh… anti-wheels) but in any case…. the small training time and the inherit random nature/path of gradient decent the final neuronal weights will always be different and when the ANN fails (hence the “stump the ANN”) it won’t always take the same path (between page reloads).

This is easier understood if I just show you.

Given this input

I got this output

Note that diagonal steps are valid so this path is technically valid but the path is far less efficient than the straight line between the two points that a human would draw/walk.

Reload the page (not required unless you are playing with this idea) and try again…

A different Path was found.

Neither was optimal but a path was found and more cells than necessary were visited.

Here’s some additional examples:

Input

Pathfinder ANN Output

Input

Pathfinder ANN Output Back tracking… ugh!

Input

Pathfinder ANN Output

I believe that’s called the sidestep slide!

Input

Pathfinder ANN Output

I mean… it’s not the path I would have chosen but it made it! 😛

If you’d like to try your hand at stumping my Pathfinder you can checkout the live demo here:

Pathfinder Online: geekgirljoy.github.io/Pathfinder_Neural_Network/

You can download all the code (for free) here:

Pathfinder Code on GitHub: https://github.com/geekgirljoy/Pathfinder_Neural_Network

And with that, have a great week everyone.


If you like my coding projects, art, bizarre opinions and writing style… consider supporting me through Patreon.

But if all you can do is Like, Share, Comment and Subscribe… well that’s cool too!

Much Love,

~Joy

Visualizing Your FANN Neural Network

At some point you will want a diagram of your FANN neural network.

Example Diagram

Programmatically generated diagram of XOR ANN
Programmatically generated diagram of XOR ANN
Programmatically generated XOR ANN Stats
Programmatically generated XOR ANN Stats

Reasons May Include:

  • You need artwork for your fridge or cubical and Van Gogh’s Starry Night was mysteriously unavailable!
  • You want an illustration to help potential investors understand some of the technical aspects of how your AI startup works.
  • You’re trying to convince the good people who enjoy your work to throw gobs of cash at your Patreon. 😛

But.. Your exact reasons may very! 😉

None the less, read on because I’m giving you 100% free & fully functional code and explaining how it works.

I’m not even asking for your email address!

 

Continue reading “Visualizing Your FANN Neural Network”

How To Split RBG Color Channels Using PHP

Today were going to look at splitting RBG colors into separate channels.

Your reasons for wanting to do this may certainly vary but it’s likely that you broadly fall into one of these categories:

  1. You like the idea of generating art using code.
  2. You have a Neural Network that needs the ability to see in color.
  3. You want to recreate “Predator Vision”.

OK… “Predator Vision” takes a few more steps but after reading this post you will be well on your way… or the whole neural network color vision thing.

Like… you know, whatever floats your boat!

In any case, there will be something for everyone because I have included pretty pictures and code! 😛

Continue reading “How To Split RBG Color Channels Using PHP”

Pathfinder Visual Interface

Meet Pathfinder’s New Look!

What is Pathfinder?

I recently wrote a tutorial where I introduce the Pathfinder neural network and cover how it works and I provided fully functional code as well as a training set to get you and Pathfinder working from scratch!

You can find that over here if you are interested: Pathfinding From Scratch Using a Neural Network

8 Direction Stepping
8 Direction Stepping

Pathfinder is an example of a neural network that is capable of plotting an 8 direction step path from a starting position in a 5×5 grid to an ending position in that grid.

I donated the Pathfinder ANN example to the Official FANN PHP Repo and you automatically obtain a copy over there for free when you download the FANN PHP extension. 😉

Pathfinder on YouTube

If you have been following me for a little while you may have even seen my YouTube Pathfinder demonstration video. Go ahead and give it a play, it’s kinda fun to watch! 🙂

Note: The experience of the Pathfinder Visual Interface (PVI) application differs slightly from this video as this video demonstrates the pathfinder neural network operating rather than the PVI, however it is quite similar. The main difference is that this example is automated to execute a series of paths whereas the PVI allows you to manually set the start and stop positions one at a time.

 

Well, now I am announcing the release of a Visual Interface for Pathfinder!

 

What’s the Pathfinder Visual Interface (PVI)?

The PVI is a front-end GUI application for Pathfinder and it comes with a slightly customized and streamlined version of my Pathfinder Neural Network.

Instead of having to manually run the training process, Pathfinder will automatically generate its mind file (pathfinder_float.net) for you from the available (and modifiable) training data on your web server, however I do provide you with a fully trained version from the start to work with to make it even easier to get started!

Additionally, the customized version of Pathfinder comes with basic single user salted & hashed password security with session handling so you could improve and expand Pathfinder as needed without worrying about unauthorized access to your web server running Pathfinder.

The Pathfinder Visual Interface was created using Unity 3D and utilizes C# under the hood.

The Pathfinder Visual Interface is compiled for Windows, Mac and Linux, both 32 bit (x86) & 64 bit (x64) executables are available.

I may make WebAssembly as well as Android and iOS versions available if there is enough interest.

What’s the Difference?

Unlike the PVI version of Pathfinder, the open source version of Pathfinder runs in a browser and is strictly text based (stylized with CSS) which looks like this:


Testing Pathfinder:

10000
00000
00000
00000
00001

Results:

10000
01000
00100
00010
00001


Completely functional, however not very nice to look at, and you have to interact with Pathfinder directly from the source code. :-/

Now here is the same example as above but using the PVI:

 

 

 

 

 

Clearly it’s easier to test and work with your Pathfinder Neural Network and dare I say more fun too! 😛

 

What’s Required?

The Pathfinder ANN relies on PHP so you will need a web server like XAMPP if you will be running it on your local machine or a web hosting account that grants you administrative access via SSH (Secure Shell) and or any other system or implementation that allows you to install PHP extensions as an administrator.

If you want to get started quickly you can use c9.io for free (not a sponsor) and don’t want to or are unable to install a web server on 127.0.0.1.

Pathfinder also requires the free (but very powerful) FANN (Fast Artificial Neural Network) Library to be installed on the machine that is serving and supporting Pathfinder.

I do recommend using secure connections so if you are running Pathfinder from your website you should be encrypting your traffic using SSL Certificates (HTTPS) to make sure that the data exchanged with Pathfinder (as well as your password and other sensitive data) is not exchanged as plain text.

Note that If you are a Developer level supporter on Patreon and want to modify the PVI app you will also need to obtain a free copy of Unity 3D however it is not needed if you only want to to use or modify the neural network which is written in PHP.

 

What could you actually do with with the PVI?

The PVI exchanges it’s grid data with the Neural Network running on your web server so you are not limited by local resources and as such Pathfinder and the PVI make excellent starting points to build games as well as robotics & IOT projects.

If you are the kind of person asking questions like how can I deploy a neural network to interface with my game or web capable Arduino or Raspberry Pi project, and you also have some basic web server knowledge, this might be the right project for you! 😉

 

What do I actually get?

If you are looking to bypass the development of an extensible web based pathfinder neural network and would like a cross-platform (Win, Mac, Linux) tool to interface with the ANN for testing you should support me over on Patreon at the User level which is perfect for teachers and students looking to study PHP, Unity 3D or pathfinding using neural networks.

User

For only $5 Users Get:

  • Access to the open source customized PHP based Pathfinder UI edition and the closed source Cross-Platform (Win, Mac, Linux) executable of the Pathfinder Visual Interface application.

 

If you also want to be able to modify the PVI application so that it is customized to your project needs you should support me over on Patreon at the Developer level.

For only $25 Developers Get:

  • Access to the open source customized PHP based Pathfinder UI edition and the closed source Unity 3D project used to create the Cross-Platform Pathfinder Visual Interface application that you can freely modify to meet your project needs.
  • Additionally developers receive a commercially permissible reuse license!

Users may use the Pathfinder Visual Interface (as is) in a private or commercial setting but you may not redistribute resell it or reverse engineer or decompile it unless you are a Developer level supporter Patreon.

If you would like to get yourself a copy of the Pathfinder Visual Interface it is available now on Patreon!

Next week I will be releasing another tutorial so please Like, Comment & Share this post with your friends and followers on your social media platforms and don’t forget to click the follow button to get notified when I post something new.

If would like to suggest a topic or project for an upcoming post feel free to contact me.

Much Love,

~Joy

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: