Clojure Machine Learning - Generating Art (Feed Forward, Hill Climb)

in #utopian-io7 years ago (edited)

What Will I Learn?

  • You will learn how to create a feed forward neural network in Clojure
  • You will learn how to build a hill climb algorithm
  • You will learn how to use Clojure Quil to sketch drawings

Requirements

  • A firm knowledge of Lisp or Clojure
  • A decent knowledge of Linear Algebra and Machine Learning concepts
  • The Clojure Leiningen build tool and Java JDK 8+

Difficulty

  • Advanced

Description

In this Clojure tutorial, we use the Quil library to build out a picture/sketch generating Feed Forward, Hill Climbing Neural Network. There are various ways to approach this type of problem in Clojure. Clojure has such a small but powerful core set of language features that we can leverage to build our Feed Forward Neural Network with very few lines of code.

First, we build out a bunch of generic mathematical functions. We need functions to help us preform Linear Algebra on the Clojure Vector data type. This includes functions that allow us to preform Multiplication, Subtraction and the Dot Product. We also create a few functions that allow us to generate random Matrices and Vectors based on the inputs. We then implement basic versions of the Sigmoid function and the Tangent Hyperbolic function which we will use as our Transfer Functions. These functions allow us to normalize the inputs and outputs based on the weighs that we get from our network.

Next, we build out a library that allows us to actually construct our Feed Forward Neural Network. We use Clojure Records to build a network of layers which we can then recursively iterate through and preform operations on. We add some basic genetic algorithms in the form of our Hill Climb Algorithm. we use an arbitrary value to incrementally search for numbers that work as solutions to our problem. We have expected outputs which we are trying to train our network to work towards.

We finally use the network inputs and outputs along with the Quil library to actually draw out random pictures. The inputs work as points that exist between our X and Y coordinates of the window and our outputs are used to assign values to the colors that fill the created shapes. The more Neurons, Layers and Outputs assigned to the Neural Network, the more complex and interesting the sketch will be. More complex Networks will also tax the computer's resources as a result of a lack of GPU optimization in this particular implementation.

The source code for this project can be found here

Video Tutorial



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by Tensor from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Your contribution cannot be approved because it does not follow the Utopian Rules, and is considered as plagiarism. Plagiarism is not allowed on Utopian, and posts that engage in plagiarism will be flagged and hidden forever.

Plagiarised from here.

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.029
BTC 62017.93
ETH 2409.75
USDT 1.00
SBD 2.65