Deep Learning with Python, TensorFlow, and Keras tutorial

sentdex · 1.4M views · 2018 · 20:34

Open on YouTube

Machine learning & deep learningPython, Ruby & scripting languagesEducation & learningtutorialdated

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they followed when asking about errors and follow-up problems in their first MNIST and Keras neural network projects.

Recommended by 0 people across 0 different months, 2018 to 2020.

What it is

A roughly 20-minute beginner tutorial by sentdex (Harrison Kinsley) that builds a simple neural network in Python using TensorFlow and Keras. It trains on the MNIST handwritten digit dataset and walks through a Sequential model, normalization, training and prediction.

What people said

Cites Frieder Hannenheim · 2018-09 · Stack Overflow · on “Importing Pylot causes "invalid syntax" error in flask.py”

I'm new to Python and I want to replicate this tutorial: [this video] but when I try importing Matpotlib.pylot I get this error:"ModuleNotFoundError: No module named 'matplotlib.pylot'" so now I tried installing Pylot manually but it gets me an syntax error: D:\Python>pip3 install --upgrade --no-cache-dir pylot Collecting pylot Downloading [LINK] (2.8MB) 100% |████████████████████████████████| 2.8MB 5.1MB/s Collecting Flask==0.10.1 (from pylot) Downloading [LINK] (544kB) 100% |████████████████████████████████| 552kB 4.1MB/s Collecting Flask-Classy==0.6.10 (from pylot) Downloading [LINK] Collecting Flask-Assets==0.10 (from pylot) Downloading [LINK] Collecting flask-recaptcha==0.3 (from pylot) Down

Cites Matija · 2019-03 · Stack Overflow · on “jupyter notebook's kernel keeps dying when I run the code”

I made my first steps in deep learning by following this tutorial [this video] , and everything was going well until I needed to train the network in jupyter notebook. I tried almost everything and I always get this error The kernel appears to have died. It will restart automatically. When I check terminal I can see this [I 18:32:24.897 NotebookApp] Adapting to protocol v5.1 for kernel 0d2f57af-46f5-419c-8c8e-9676c14dd9e3 2019-03-09 18:33:12.906756: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA 2019-03-09 18:33:12.907661: I tensorflow/core/common_runtime/process_util.cc:69] Creati

Cites Atreyo Bhattacharjee · 2019-05 · Stack Overflow · on “Why do we use numpy.argmax() to return an index from a numpy array of predictions?”

Let me preface this by saying, I am very new to neural networks, and this is my first time using numpy, tensorflow, or keras. I wrote a neural network to recognize handwritten digits, using the MNIST data set. I followed this tutorial [this video] by Sentdex and noticed he was using print(np.argmax(predictions[0])) to print the first index from the numpy array of predictions. I tried running the program with that line replaced by print(predictions[i]) , (i was set to 0) but the output was not a number, it was: [2.1975785e-08 1.8658861e-08 2.8842608e-06 5.7113186e-05 1.2067199e-10 7.2511304e-09 1.6282028e-12 9.9993789e-01 1.3356166e-08 2.0409643e-06] . My code than I'm confused about is: predictio

Cites Joel Banks · 2019-06 · Stack Overflow · on “How to test my own hand drawn numbers in a neural network”

I followed this [this video] tutorial on how to make a neural network. Everything works great and I feel like I have a pretty solid understanding on everything I did. I've seen somewhere that people can draw a number on screen, and then run the model to see if it can guess it correctly. I can't find how to do this (To clarify, I wan't to draw one number in my program and test it, not create a whole dataset and load that in) I believe I need to use numpy (though I'm not sure) and then save that as a variable that is 28x28 pixels, black and white, and then have the model predict what it is. Is this correct? Could someone help point me in the right direction? My code is the same as the one in the vi

Cites Shin Jira · 2019-10 · Stack Overflow · on “How can I change my data to make it work with loss: mean squared error?”

I am using the mnist dataset(digits), and would like to implement mean squared error loss function, however I have the following error: ValueError: A target array with shape (60000, 1) was passed for an output of shape (None, 10) while using as loss mean_squared_error . This loss expects targets to have the same shape as the output. this is my code: Originally, I tried sparse_categorical_crossentropy Code modified from: [this video] import tensorflow as tf mnist = tf.keras.datasets.mnist (x_train, y_train), (x_test,y_test) = mnist.load_data() x_train = tf.keras.utils.normalize(x_train, axis = 1) x_test = tf.keras.utils.normalize(x_test, axis = 1) model = tf.keras.models.Sequential([ tf.keras.laye

Cites Micheal Lin · 2019-10 · Stack Overflow · on “AttributeError: 'list' object has no attribute 'shape' occurs in PyCharm but program functions perfectly in Jupyter Notebook”

I'm following a tutorial on deep learning and I used Jupyter Notebook to follow along. The program ran with no issues. However, when I copied my code into PyCharm after installing all the necessary libraries, I ran the code and at the very end, after running through the training, this error appeared: AttributeError: 'list' object has no attribute 'shape'. Can anybody tell me why this error occurs and how to fix it? Tutorial link: [this video] Code: import tensorflow as tf import numpy as np fashion_mnist = tf.keras.datasets.fashion_mnist (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data() x_train = tf.keras.utils.normalize(x_train, axis=1) x_test = tf.keras.utils.normalize(x_test, ax

Cites Neil · 2019-11 · Stack Overflow · on “Passing an array into sequential neural network model”

So I've followed along with this [this video] video on creating a sequential neural network and giving it the MNIST data set to make predictions on. I've also got a flask web server and with it I am trying to pass an image that I've gotten from a canvas drawing app, resize it to 20x20 as that's the dimensions of the MNIST images, convert it to grayscale and then into an array using numpy and finally give it to my model and have it make a prediction. I will then pass that back to the webpage. However I'm getting the error: Error when checking input: expected sequential_1_input to have 3 dimensions, but got array with shape (20, 20) How do I make the array 3 dimensional? The model: model = kr.model

Cites Neil · 2019-12 · Stack Overflow · on “Sequential model always predicts 5”

So I've got a sequential model from mostly following along with this [this video] video. I've also got a drawing app done in JS and am sending the contents of that canvas to a flask server using JQuery. All of that seems to be working fine but when I give my model the image from the canvas and call predict it always gives me back the same exact response. The values at each index are always the same. Am I missing something simple? Am I calling the predict wrong in the server or is it something to do with the model itself? It gets the predictions correct in the notebook. Thanks for your time! Flask server: model = load_model('MyModel.h5') imageWidth = 28 imageHeight = 28 dim = (imageWidth, imageHei

Cites jace · 2020-05 · Stack Overflow · on “Input 0 of layer dense is incompatible with the layer: expected axis of -1 of input shape to have value 784 but received input with shape [None, 840]”

I'm trying to implement a tensorflow project where the user draws a number and the model recognizes it. So far I have the user draw the number on a tkinter canvas, save the image, then convert that image again to a numpy array for the model prediction. But I keep getting the following error: ValueError Input 0 of layer dense is incompatible with the layer: expected axis of -1 of input shape to have value 784 but received input with shape [None, 840] Here's the code: def draw(event): color='black' x1, y1 = (event.x-1), (event.y-1) x2, y2 = (event.x+1), (event.y+1) c.create_rectangle(x1,y1,x2,y2, fill=color, width=10) blank.rectangle([x1-4,y1-4,x2+4,y2+4], fill=color, width=10) def end(event):

Cites sneeze_shiny · 2020-08 · Stack Overflow · on “Python error in calculating deep learning model value loss - "ValueError: Data Cardinality is ambiguous"”

Despite having previous coding experience in R and Python, I am brand new to Jupyter Notebook, tensorflow, and deep learning model-building, so I am looking for someone to help me diagnose this error. I am following a tutorial demonstrating how to classify imagery with deep learning modules ( [this video] ). The model loads the mnist image dataset, and classifies the images between 1-10. Running three epochs, the overall model accuracy comes out to 97%. #Import module import tensorflow as tf #Import image dataset mnist = tf.keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() #Defining training and test x_train = tf.keras.utils.normalize(x_train, axis = 1) x_test = tf.ker