MLearning.ai
Published in

MLearning.ai

Coding Neural Networks in Carbon: Part 1

New language, new possibilities

Photo by Markus Spiske on Unsplash
$ cd carbon-lang/explorer/testdata
$ mkdir neural_nets
$ cd neural_nets
$ touch basic_neural_net.carbon

Intuition

y = mx + c

A neuron by Cornell University
package ExplorerTest api;
package ExplorerTest api;//declare a function called Main that returns an int value
fn Main() -> i32 {
var inputs: [i32; 3] = (1, 2, 3);
var weights: [i32; 3] = (3, 2, 8);
var bias: i32 = 3;
}
//the complete code should look like this
package ExplorerTest api;
fn Main() -> i32 {
var inputs: [i32; 3] = (1, 2, 3);
var weights: [i32; 3] = (3, 2, 8);
var bias: i32 = 3;

var output: i32 = inputs[0] * weights[0] +
inputs[1] * weights[1] +
inputs[2] * weights[2] + bias;
Print("The output is:{0}", output);
return 0;
}
$ cd carbon-lang
$ bazel run //explorer -- ./explorer/testdata/neural_nets/basic_neural_net.carbon
Image from the author

--

--

Data Scientists must think like an artist when finding a solution when creating a piece of code. ⚪️ Artists enjoy working on interesting problems, even if there is no obvious answer ⚪️ linktr.ee/mlearning 🔵 Follow to join our 28K+ Unique DAILY Readers 🟠

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mwanikii

Writer. Techie. History buff. If it changes the world I’m on its case. Open for gigs… freddynjagi@gmail.com! Published by the Writing Cooperative.