Skip to content

Notes from auditing week 1 materials

Insights

In traditional programming, a programmer has to formulate or code rules manually, whereas, in Machine Learning, the algorithm automatically formulates the rules from the data.

The Traditional Programming Paradigm

(Rules, Data) -> Answers

The Machine Learning Paradigm

(Answers/Labels, Data) -> Rules

Coding the "Hello World" of Deep Learning with Neural Networks in Tensorflow

to figure out the relati onship between x and y, given a training set with a small number of data points.

import tensorflow as tf
import numpy as np
from tensorflow import keras
print(tf.__version__)

## Build a simple Sequential model
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])

## Compile the model
model.compile(optimizer='sgd', loss='mean_squared_error')

## Declare model inputs and outputs for training
xs = np.array([-1.0,  0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)
ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)

## Train the model
model.fit(xs, ys, epochs=500)

## Make a prediction
print(model.predict([10.0]))

Jupyter Notebooks