Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit af71d3b

Browse files
authored
🔁 Update README
1 parent b8428e4 commit af71d3b

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

‎README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ Learning **AI Deep Learning** / **Machine Learning**.</br>
55
I tried to keep it as short as possible, but Truth needs to be told, **Machine Learning** is a big topic. </br>
66
In this Repository, the focus is mainly on **TensorFlow**.
77

8-
## What is a neural network?
8+
## What is a neural network? 🌐
99

1010
A basic **neural network** consists of an **input layer**, which is just **your data, in numerical form**. After your **input layer**, you will have some number of what are called **"hidden" layers**. **A hidden layer** is just in between your input and output layers.</br> ***One hidden layer means you just have a neural network. Two or more hidden layers? you've got a deep neural network!***
1111

1212
![neural network](Images/artificial-neural-network-model.png)
1313

14-
## What is a Tensor?
14+
## What is a Tensor? 🔢
1515

1616
Each operation takes a **Tensor** as an Input and outputs a **Tensor**.</br>
1717
A **Tensor** is how Data is represented in **TensorFlow**.</br>
@@ -22,6 +22,32 @@ This would be a **normalized three-way-tensor**.</br>
2222

2323
![neural network](Images/tensor.png)
2424

25+
## 📝 Example Code with Comments 📝
26+
```
27+
import tensorflow as tf # deep learning library. Tensors are just multi-dimensional arrays
28+
29+
mnist = tf.keras.datasets.mnist # mnist is a dataset of 28x28 images of handwritten digits and their labels
30+
(x_train, y_train),(x_test, y_test) = mnist.load_data() # unpacks images to x_train/x_test and labels to y_train/y_test
31+
32+
x_train = tf.keras.utils.normalize(x_train, axis=1) # scales data between 0 and 1
33+
x_test = tf.keras.utils.normalize(x_test, axis=1) # scales data between 0 and 1
34+
35+
model = tf.keras.models.Sequential() # a basic feed-forward model
36+
model.add(tf.keras.layers.Flatten()) # takes our 28x28 and makes it 1x784
37+
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu)) # a simple fully-connected layer, 128 units, relu activation
38+
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu)) # a simple fully-connected layer, 128 units, relu activation
39+
model.add(tf.keras.layers.Dense(10, activation=tf.nn.softmax)) # our output layer. 10 units for 10 classes. Softmax for probability distribution
40+
41+
model.compile(optimizer='adam', # Good default optimizer to start with
42+
loss='sparse_categorical_crossentropy', # how will we calculate our "error." Neural network aims to minimize loss.
43+
metrics=['accuracy']) # what to track
44+
45+
model.fit(x_train, y_train, epochs=3) # train the model
46+
47+
val_loss, val_acc = model.evaluate(x_test, y_test) # evaluate the out of sample data with model
48+
print(val_loss) # model's loss (error)
49+
print(val_acc) # model's accuracy
50+
```
2551
## Resources & Links:
2652
Deep Learning: https://pythonprogramming.net/introduction-deep-learning-python-tensorflow-keras/ </br>
2753
TensorFlow Overview: https://www.youtube.com/watch?v=2FmcHiLCwTU

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /