Tuesday, August 23, 2016

Machine Learning - Very Basic Code

Machine Learning!

Sounds complicated?  Well, it can be.  But I've put together some super simple code at this GitHub repo github.com/hchiam/machineLearning which has my .py Python files (plus one from iamtrask) that you can run on your own computer (I like to use Terminal commandline)... or you can run the code yourself right here on this page!

Instructions:
= Run Code
= Edit Code

The following four code examples are four different neural nets, ranging from differing approaches to giving "feedback" to the "neuron connections", to testing out a layered version.  Each example is commented (Python uses the "#" character for comments, which should turn green in these interfaces).


neuralNet1.py:  Version 1.  Example of a very simplified neural network, and using a sensitivity parameter.



neuralNet2.py:  Version 2.  Example of a very simplified neural network, with weighting based on "responsibilities" of different inputs.  (This one seems really fast but may be unstable or naive because it's basically using learning sensitivity = 1.)



neuralNet3.py:  Version 3.  Example of a very simplified neural network that combines version 1 and version 2, combining sensitivity parameter and "responsibilities" of different inputs.
 


neuralNet4_Layered.py:  Version 4.  Example of a neural network that kinda combines version 2 and version 3:  uses learning error sensitivity, but now also uses a hidden layer. It also has my own "transformed" (i.e. translated) version of the sigmoid function that goes from -1 to 1.


Again, note that I created these code examples to help myself wrap my head around the very basic basics of machine learning, specifically neural networks.  Hopefully they help you too, through experimenting and reading the comments.  You can Google the rest.


LINKS TO INTERESTING READS/FINDS for Machine Learning:
  • Neural network playground:  here.
  • Python neural network in 11 lines of code:  here.
  • Python genetic algorithm in 15 lines of code:  here.
  • Ruby code for "suggested posts" via machine learning:  here.
  • Python Recurrent Neural Network for generating Shakespeare and more:  here.
  • A longer read but great code examples running in-browserhere.
_________________________

LINKS TO OTHER STUFF: 

Favourites
Programming
Original Art
Games

Chinese Learning Projects:
 - Book
 - HSK 1
 - HSK 5
 - Homonyms Mnemonics

No comments:

Post a Comment