Convolutional Neural Networks – Deep Learning basics with Python, TensorFlow and Keras p.3

Welcome to a tutorial where we’ll be discussing Convolutional Neural Networks (Convnets and CNNs), using one to classify dogs and cats with the dataset we built in the previous tutorial.

Text tutorials and sample code: https://pythonprogramming.net/convolutional-neural-network-deep-learning-python-tensorflow-keras/

Discord: https://discord.gg/sentdex
Support the content: https://pythonprogramming.net/support-donate/
Twitter: https://twitter.com/sentdex
Facebook: https://www.facebook.com/pythonprogramming.net/
Twitch: https://www.twitch.tv/sentdex
G+: https://plus.google.com/+sentdex

215 comments

  1. Florian Linscheid on

    That input_shape thing is not completely clear to me. Why do you specify the shape to (50,50,1) in the first layer, but in the second you don’t?
    And where would the Dropout come into place here?

    Anyway, thanks for the tutorial 🙂

    Reply
  2. Cineva in comentarii on

    nice cat-o-cup

    btw i have a problem loading with that pickle thing so to fix that I used the loading code from last tutorial
    and i have some questions : 1. why you use capital X and non capital y
    2. [this is not a question] can you please tell us consequences if you put a value too big or too small , cuz i dont know if these values work everytime or i need to do all by myself

    Reply
  3. Aneesh Babu on

    hy, i am making a cnn based on mnist dataset to recognize the digits.but i am getting correct predictions on my test.csv but on raw data(raw image ),i am getting wrong predictions. i duuno why and nyc video.

    Reply
  4. Maaz Syed Mohammad on

    Great tutorial !
    I know you’ve been doing the starcraft series but wanted to know if you can do a tutorial based on the ‘vizdoom’ api and this cnn model
    thanks again…

    Reply
  5. Geet Sameer on

    Awesome tutorial. Why are you taking odd sized kernels? Can we use even sized kernels? Why we prefer taking odd sized kernels? Are there any advantages?

    Reply
  6. Rishik Mourya on

    I know this series is gonna as great as always. I would like to suggest to make tutorials on Capsule Networks also, CNN and these are quite similar yet capsule networks are pretty effective in terms of versatility.

    Big fan 😊

    Reply
  7. Wolf Rage on

    I know this series is gonna as great as always. I would like to suggest to make tutorials on Capsule Networks also, CNN and these are quite similar yet capsule networks are pretty effective in terms of versatility.

    Big fan 😊

    Reply
  8. Yunusa Muhammed on

    Awesome as always, will wait patiently for the next video and I hope to hit “Join” button too when i am less busy to get the max out of your brain 😀

    Reply
  9. King Neptune on

    hey sentdex, nice tutorial I’ve been binge watching your tutorial videos and compared to your previous convolutional neural network videos I noticed a few differences. For conv2D you didn’t increase the number of features(for both layers you kept it at 64) whereas previously you increased it. Why is that? Moreover, why did we not use dropout and why did we use the ‘sigmoid’ activation function over ‘softmax’? And also wanted to say thank you for the great content!

    Reply
  10. Rickey Carter on

    re:layer, I think the origin is from the data graph that is formed. It’s another layer/processing step that gets applied, and the order of the operations is somewhat tunable (e.g., activate before normalization or vice versa).

    Reply
  11. Benjamin Dubreu on

    Bobby Fisher’s 21 move brilliancy is a video I watched at least 10 times. Apparently we are in the same team, since Youtube’s ML algorithms tell you to watch it ^^

    Reply
  12. Sourav Ghosh on

    I have a very specific requirement in my project at work. Can you please tell how i can get i touch with you so that i can discuss with you briefly about it and get your views on how to proceed on it?
    Best regards,
    Sourav

    Reply
  13. Brother Lui on

    Hi Harrison, doesn´t the Dense(64) layer at 11:30 need an activation function? I added another “relu” there and got better accuracy.

    Reply
  14. Gautam J on

    A tutorial on keras callbacks such as EarlyStopping and ModelCheckpoint would be nice.

    Also, I would love if you could explain Image Augmentation in Keras for CNN.

    Reply
  15. Piotr Wln on

    Say I want to build a classifier that tells me if a person is wearing glasses or not. Would you train your model using photos containing whole faces or just the eyes?

    Reply
  16. yasser skillful on

    Hi Harrison, thanks a lot for the nice effort, kindly I do have a question, why did you pass 64 to Conv2D, is it the number of the filters in the conv layer or what exactly?

    Reply
  17. Benjamin Gutzmann on

    You should finish the video with saving the model to the drive… anyway if there’s something to improve on the model, that could be done again in the next video.

    Reply
  18. UnlikelyMustard on

    Hey, next time can you please explain how/why you chose to have this specific model architecture? This is a common issue I have with ML models. I never know which layer I should have next or how to choose the size of layers, etc. Is it just 100% trial and error or is there something else more to it that helps you figure it out?

    Reply
  19. David Edwards on

    You can write the Conv layer as “Conv2D(128, (3, 3), activation=’relu”)” where you do not have to have a separate line for the activation

    Reply
  20. James Oliver on

    Been meaning to ask you about the drones in background, are you still into the hobby? I too have built many drones and neural networks lol.

    Reply
  21. Timothy Yee on

    1) code does not seem to want to run on jupyter notebook. The kernel keeps dying on the fit function do you know what the fix is? 2) When I run the code on sublime, all my cores are firing and it takes my i7 8700k 3minutes to go through 1 epoch. How did your code run so fast? 3) I’m not sure if they may be contributing to questions 1 and 2, but I had to use tensorflow.python.keras.models/layers instead of tensorflow.python.models/layers, otherwise I get module not found error. Do you know what the issue is? 4) If I re-run the same code on idle, it takes 5 minutes for 1 epoch and the cpu is not maxed out. 5) I reinstalled tensorflow on python and conda and now tensorflow does not seem to work on sublime or conda(I had 1.8 before updates, now i’m using 1.10 on python and 1.9 on conda). This is so annoying. 6) after the tensorflow reinstall, I got sublime and to work, I believe it ran using my GPU – 29s. I re-ran it again to confirm my results and I’m now getting gpu issues with cuda. Why must this be so difficult… help appreciated!

    Reply
  22. Kasper Juunge on

    7:56 Is it a programmer-thing to have ugly mugs?? :p Stefan Mischook also has an ugly snake mug, for when he talks about python!

    Reply
  23. antonio perez on

    Hi.

    when I run the code part

    pickle_in = open (“X.pickle”, “rb”)
    X = pickle.load (pickle_in)

    There is an error:

    FileNotFoundError: [Errno 2] No such file or directory: ‘X.pickle’

    Reply
  24. Dominik Podlipniak on

    Training this CNN with more dimensionality filter than 64, takes ages on my MacBook Pro 2017. I guess I’m just gonna train this with the help of my GPU on my PC.
    Is it normal that CNN’s are much more computationally expensive? I never encountered problems like this in regular deep NN.

    By the way, amazing tutorial series ! Everything is very clear presented and helpful. Thanks Harrison ! 🙂

    Reply
  25. Tim Webb on

    You are consistently capitalizing X, but use a lowercase y. Is that a convention I am unaware of? It seems like an easy way to generate Exceptions when you call an x instead of an X.

    Reply
  26. Vignesh Padmanabhan on

    lol, I am doing on my Entry level 2016 MacBook pro and for each epoch, it takes 9.65 min… 😂 at the end of 3 epoch .. my accuracy is .5264

    Reply
  27. Gabe Mallin on

    Hi,
    I’m following your tutorials on the raspberry pi 3B+ and I’m questioning a part for the ssh setup. As my home computer has chrome os is won’t let me use putty as a ssh client. What other client would you recommend? A quick search lead me to Terminus but I’m unsure.

    Thanks!

    Reply
  28. Artur Müller on

    Could you make a tut how to use different models from the tensorflow model zoo and explain which model should be used for which task? I am using your old tensorflow guide for image recognition and am having a hard time getting into the different models.

    Reply
  29. Artur Mueller Romanov on

    Could you make a tut how to use different models from the tensorflow model zoo and explain which model should be used for which task? I am using your old tensorflow guide for image recognition and am having a hard time getting into the different models.

    Reply
  30. 7characters on

    Would the model still work as well if, when training, you substituted all of the cats with random images?
    So the network would be trained to know what a dog is, and anything but is a cat… will the predictions be as accurate?

    Reply
  31. jaysin scars on

    help needed bro, need to account for possible win or loss in a soccer match, tried probability but i suck at that, any machine learning tools or method i should use?

    Reply
  32. Vikash Rajak on

    How to find candlestick patterns on a daily chart with Python3???? Can u make a video on it? I have successfully made a program on python that finds a doji pattern, but it would be better if u make a video on other candlestick patterns….. please reply!!!

    Reply
  33. wow2fun on

    i got this error:
    ValueError: Error when checking target: expected activation_2 to have 2 dimensions, but got array with shape (24946, 50, 50, 1)
    please advise thx.

    Reply
  34. IMAKE on

    You can add the “layers” as an array “model = Sequential ([ flatten(), Dense(10), Activation(‘relu’) ])” instead of using the model.add() function every time.

    Reply
  35. Vignesh Padmanabhan on

    This program runs on mac but not on windows. I am getting this error as stated below

    —————————————————————————
    TypeError Traceback (most recent call last)
    in ()
    5 for img in os.listdir(path):
    6 img_array = cv2.imread(os.path.join(path,img),cv2.IMREAD_GRAYSCALE)
    —-> 7 plt.imshow(img_array,cmap=’gray’)
    8 plt.show()
    9 break

    ~Anaconda3libsite-packagesmatplotlibpyplot.py in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, hold, data, **kwargs)
    3208 filternorm=filternorm, filterrad=filterrad,
    3209 imlim=imlim, resample=resample, url=url, data=data,
    -> 3210 **kwargs)
    3211 finally:
    3212 ax._hold = washold

    ~Anaconda3libsite-packagesmatplotlib__init__.py in inner(ax, *args, **kwargs)
    1865 “the Matplotlib list!)” % (label_namer, func.__name__),
    1866 RuntimeWarning, stacklevel=2)
    -> 1867 return func(ax, *args, **kwargs)
    1868
    1869 inner.__doc__ = _add_data_doc(inner.__doc__,

    ~Anaconda3libsite-packagesmatplotlibaxes_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
    5499 resample=resample, **kwargs)
    5500
    -> 5501 im.set_data(X)
    5502 im.set_alpha(alpha)
    5503 if im.get_clip_path() is None:

    ~Anaconda3libsite-packagesmatplotlibimage.py in set_data(self, A)
    648 if (self._A.dtype != np.uint8 and
    649 not np.can_cast(self._A.dtype, float, “same_kind”)):
    –> 650 raise TypeError(“Image data cannot be converted to float”)
    651
    652 if not (self._A.ndim == 2

    TypeError: Image data cannot be converted to float

    Reply
  36. James Farmstone on

    Could you do an example of a neural net for number-based data like feeding a list of variables directly rather than image-based data?

    Reply
  37. Boris Papić on

    Why are the first two layers conv2d and the third one is dense? I tried switching the second conv2d layer to dense and it had better accuracy but took a few seconds more to train. is it for balance between time and accuracy? Great videos and thank you for making these

    Reply
  38. Cineva in comentarii on

    i’m trying to make my own classifier with 3 classes instead of 2 , but I don’t know what I need to change in ‘Training’ to make it work

    edit: the problem i had was the shape cuz i used RGB , the new problem i have now is now my loss goes higher and accuracy lower

    Reply
  39. Nikolay Ivankin on

    You can add layer with Activation inside:
    model.add(Dense(256, activation=’relu’))
    It allows you to choose activation function to each of them separately

    Reply
  40. Nidiyan Rajendran on

    Thanks so much for the tutorial – However, I had a quick question:
    After we train our model, how would we actually use it. For example, if I were to go out and take a picture of a dog/cat, would I be able to feed it through the network and see what it predicts?

    Reply
  41. Angelo Rafael Santos on

    please help
    i have this error:

    7 Y = pickle.load(open(“Y.pickle”, “rb”))
    8
    —-> 9 X = X/255.0
    10
    11 model = Sequential()

    TypeError: unsupported operand type(s) for /: ‘NoneType’ and ‘float’

    Reply
  42. Hannah Humphreys on

    Introduction to Machine Learning for Data Science

    > The Impacts Machine Learning and Data Science is having on society.
    >To know what problems Machine Learning can solve, and how the Machine Learning Process works.

    #MachineLearning #DataScience

    http://bit.ly/2MfrT8t

    Reply
  43. Quang Huy Ngô on

    Hi Mr. Sentdex! Why did you add explanation to each of line? It should’ve been easier to understand the code. Anyways, this is a great video. Thank you.

    Reply
  44. Patrick Littlefield on

    Hey,
    Could you maybe expand a bit on the exact purpose of the ‘Dropout’ function? We imported ‘Dropout’ but I don’t think we used it anywhere in the code. Did you decide on the fly to not include a dropout function or was it perhaps just simply an oversight?

    Reply
  45. CHRISTOPHER ADOLFO ORDUÑA DE LEON on

    dude i got this error ValueError: Error when checking target: expected activation_3 to have 2 dimensions, but got array with shape (25000, 50, 50, 1) i want to know why could you help me?

    Reply
  46. WALLSNAP on

    i didn’t get the x = x/255.0 because x is numpy array which consists of more numpy arrays right… and just dividing it by 255 seems weird. I’d appreciate if you could further elaborate

    Reply
  47. Carl on

    Very nice tutorial thanks!

    I’m just wondering how your fitting operation runs so fast? On my computer each epoch is taking like 8 minutes! It runs on the CPU (is it supposed to run on the GPU somehow?) and I have a decent i7 6820k, so I was confused about how slow it was going.. (also I was using Pycharm) . If anyone got an idea, please share 🙂

    Reply
  48. Dynasty on

    Very nice tutorial thanks!

    I’m just wondering how your fitting operation runs so fast? On my computer each epoch is taking like 8 minutes! It runs on the CPU (is it supposed to run on the GPU somehow?) and I have a decent i7 6820k, so I was confused about how slow it was going.. (also I was using Pycharm) . If anyone got an idea, please share 🙂

    Reply
  49. Torgrim11 on

    You are missing regularization, which is a pity for your viewers. I recommend a dropout layer after each convolution. The theoretical background is easy. The goal is the distribute the weights as much as possible by punishing huge weight values or using random nodes each round. Hence the dropout layer.

    Reply
  50. kushagra deep on

    What hardware do you use, my gcloud n1-highmem-8 (8 vcpus and 53GB memory) took half an hour to compile the model.fit

    Any suggestions what hardware should I use in gcloud? I’m using gcloud’s Deep Learning Image

    Reply
  51. Nacer Zarguit on

    Great tutorial !
    I think it’s better that you use Jupyter notebook in your tutorials. It makes things much easier to follow.

    Reply
  52. j_bar _ on

    Can someone please help me, I did the exact same code as him, and I’m getting around 0.5 accuracy and 0.69 loss. The validation accuracy is just slightly greater than normal accuracy and validation loss is the exact same as the normal loss every time. I have been trying to tweak things all day and I end up with only minor changes in accuracy. The loss somehow always ends up at 0.69. I’m using cpu tensorflow 1.10.0 on anaconda 1.9.2

    Reply
  53. Amir Rahnama on

    Thank you for your nice tutorial, i got an error while I am compiling the model.
    #fit the model to data
    model.fit(X,y, batch_size = 32, epochs = 2, validation_split= 0.3)

    when I run the above code, I got a problem says that:
    ValueError: Error when checking target: expected activation_24 to have 2 dimensions, but got array with shape (24946, 50, 50, 1)

    All code lines above fitting the model worked properly, this pice os code has only problem that I mentioned above.
    Any suggestions?
    Thanks in advanced.

    Reply
  54. Alok Raj Gupta on

    Hi Harrison, At 12:26, in my opinion activation function is present at every layer that is why keras added it to the keras.layers !

    Reply
  55. RAJA SHASHIDHARREDDY on

    Kernel Restarting
    The kernel appears to have died. it will restart automatically.
    In jupyter notebook this popup is appearing. Anyone know about it.

    Reply
  56. Gokul Sundeep on

    I’m getting this error:
    ValueError: Negative dimension size caused by subtracting 3 from 1 for ‘conv2d/Conv2D’ (op: ‘Conv2D’) with input shapes: [?,50,50,1], [3,3,50,256].
    Can anyone help!!

    Reply
  57. Kaif Khan on

    I am getting `Memory Error` everytime, using fish dataset with 24000 images, and VGG19 model for training. Any fix for this?

    Reply
  58. RAJA SHASHIDHARREDDY on

    Kernel Restarting The kernel appears to have died. it will restart automatically. In JUPYTER NOTEBOOK this popup is appearing. Anyone know about it. I have 1050ti 4gb gpu 8gb ram pentium G2020 cpu this CNN classification possible on my system (3rd video in deeplearning basics series CNNs). THANKS.

    Reply
  59. Eduardo de Paula Lima Nascimento (Inconfidentes) on

    Hello, my code is taking too long to train this data, about 10 min per epoch, is there a way to speed up?

    Reply
  60. uchiha madara on

    hey Harrison. i used the codes that u did. but i got an error saying ‘list index is out of range’. would u mind helping me out??

    Reply
  61. Ole Andreas Utstumo on

    Anybody getting an ModeluNotFoundError on “tensorflow.keras.models”, try using just “keras.models” instead.

    Reply
  62. Ole Andreas Utstumo on

    Anybody getting an ModeluNotFoundError on “tensorflow.keras.models”, try using “tensorflow.python.keras.models” instead.

    Reply
  63. Stephen Fernandes on

    hi there , in tensorflow 1.12 you get an error during model.split in validation_split you get an error # prepare validation data , the error is expected activation 20 to have 2 dimensions but got array with shape (12470,50,50,1)

    Reply
  64. eltigremoto on

    Hi
    I need advice.
    I am building a model: 300 variables as input and 30 as output, the output are 0 or 1 for each of the 30(categorical¿?)
    What kind of layer do you recomend me for the last layer since I need the output only as 0 or 1 not floats?.

    On the other hand, on another model I am trying to make an conv1D layer on my second layer, I would like to
    take 3-5 elements of my input to 1 neuron of this conv1D layer. (3 to -5 elements from input to 1 neuron of the conv1D layer)
    any ideas?

    Thank you in advance I hope some of you genius guys can help me.

    Reply
  65. 小濱ひさえ on

    when compiling with pycharm, “OpenCV(3.4.1) Error: Assertion failed (ssize.width > 0 && ssize.height > 0) in resize” errors happen by 60 or much more times, do you know what is the error.

    Reply
  66. 郁力潔 on

    HI can you explain one more time:that why model.add(Con2D(64),(3,3), input_shape=x.shape[1:]) why this line x.shape should be set like[1: ]?
    and also I encounter some problems that I try to load some images in
    desktop. but when i set the path = DATAIR=’ C:/Users/A60182/Desktop/Example/train’
    and follow all of the code in Deeplearning lession 2, but the result shows no such file or directory:image.jpg
    I still no very clear.thanks for your vedio

    Reply
  67. Vignesh Prabhu on

    Does anyone know how this error can be solved?
    Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
    [[{{node conv2d/Conv2D}} = Conv2D[T=DT_FLOAT, _class=[“loc:@training/Adam/gradients/conv2d/Conv2D_grad/Conv2DBackpropFilter”], data_format=”NCHW”, dilations=[1, 1, 1, 1], padding=”VALID”, strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device=”/job:localhost/replica:0/task:0/device:GPU:0″](training/Adam/gradients/conv2d/Conv2D_grad/Conv2DBackpropFilter-0-TransposeNHWCToNCHW-LayoutOptimizer, conv2d/Conv2D/ReadVariableOp)]]
    [[{{node loss/activation_3_loss/broadcast_weights/assert_broadcastable/AssertGuard/Assert/Switch_3/_111}} = _Recv[client_terminated=false, recv_device=”/job:localhost/replica:0/task:0/device:CPU:0″, send_device=”/job:localhost/replica:0/task:0/device:GPU:0″, send_device_incarnation=1, tensor_name=”edge_331_l…t/Switch_3″, tensor_type=DT_BOOL, _device=”/job:localhost/replica:0/task:0/device:CPU:0″]()]]

    My Tensorflow GPU is working fine with current cuDNN and CUDA versions, as I tested this using the code:
    import tensorflow as tf
    with tf.device(‘/gpu:0′):
    a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name=’a’)
    b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name=’b’)
    c = tf.matmul(a, b)
    with tf.Session() as sess:
    print (sess.run(c))

    Reply
  68. Hamza Hafeez on

    Hello there. I can’t thank you enough for this tutorial series. You explain everything really well.

    Big Question: I wanted to ask which version of OpenCV are you using for the tutorials.

    Cause when I install OpenCV it upgrades(or downgrades numpy)and then Numpy becomes incompatible with Tensorflow-gpu.
    This issue did not occur the first time I installed it but for every other ipython file Kernel keeps restarting and since I have gone through the issue for a whole after-noon, I have come to the conclusion that Numpy is the culprit.

    Reply
  69. govamsh sai nagalla on

    FileNotFoundError Traceback (most recent call last)
    in
    4 import pickle
    5
    —-> 6 x=pickle.load(open(“x.pickle”,”rb”))
    7 y=pickle.load(open(“y.pickle”,”rb”))
    8

    FileNotFoundError: [Errno 2] No such file or directory: ‘x.pickle’

    what is this can you help me out bro

    Reply
  70. govamsh sai nagalla on

    Traceback (most recent call last):
    File “C:UsersGovamshPycharmProjectsUntitled Folderrecognize.py”, line 6, in
    x=pickle.load(open(“x.pickle”,”rb”))
    PermissionError: [Errno 13] Permission denied: ‘x.pickle’

    what to do??? i am using windows 10 any help please

    Reply
  71. Stephan Casey on

    You should go into a paid partnership with Nvidia because this video was secretly such a nice way to brag about the difference between running TensorFlow with and without GPU support!

    Reply
  72. Kelvin Koh on

    Hi, Can I know why you added conv2d layer in to the model? Because you didnt add it in the video of classification of number

    Reply
  73. Zachary Perkins on

    16:00 how did you computer do that so fast?! i have a really good computer and it took 69 seconds

    edit: I installed tensorflow-gpu and now it takes 4 seconds oh yeah

    Reply
  74. Saswath Mishra on

    hi,
    when i call model.predict on any image it always prints the same class, i used this on another dataset, can you tell me what might be wrong with it?

    Reply
  75. Liam Rice on

    Getting the following error… ValueError: Error when checking target: expected activation_3 to have 2 dimensions, but got array with shape (24946, 50, 50, 1)

    Reply
  76. A D on

    Thanks for the tutorial. One question though:

    What further steps we should take in order to construct a model which returns the bounding box (position information)?

    Do we need to do labeling (with for example labelImg)? Tfrecord? …

    Reply
  77. DAS on

    Thanks for the tutorial. One question though:

    What further steps we should take in order to construct a model which returns the bounding box (position information)?

    Do we need to do labeling (with for example labelImg)? Tfrecord? …

    Reply
  78. ROHIT HALDER on

    i am using a windows platform, so we need to // to locate the directory but when when we use os to join the paths our path induces a which throws an error stating directory not found. what shall i do?
    plz help me i am really stuck

    Reply
  79. Land of Litte Rain on

    the X=X/255.0 operation produces TypeError: unsupported operand type(s) for /: ‘list’ and ‘float’. clearly it wants numpy arrays but this is a Python list… workaround?

    Reply
  80. Ong Yau on

    HELP

    Train on 17462 samples, validate on 7484 samples
    Epoch 1/3
    —————————————————————————
    UnknownError Traceback (most recent call last)
    in
    28 metrics=[‘accuracy’])
    29
    —> 30 model.fit(x, y, batch_size=32, epochs=3, validation_split=0.3)

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonkerasenginetraining.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, max_queue_size, workers, use_multiprocessing, **kwargs)
    1637 initial_epoch=initial_epoch,
    1638 steps_per_epoch=steps_per_epoch,
    -> 1639 validation_steps=validation_steps)
    1640
    1641 def evaluate(self,

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonkerasenginetraining_arrays.py in fit_loop(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps)
    213 ins_batch[i] = ins_batch[i].toarray()
    214
    –> 215 outs = f(ins_batch)
    216 if not isinstance(outs, list):
    217 outs = [outs]

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonkerasbackend.py in __call__(self, inputs)
    2984
    2985 fetched = self._callable_fn(*array_vals,
    -> 2986 run_metadata=self.run_metadata)
    2987 self._call_fetch_callbacks(fetched[-len(self._fetches):])
    2988 return fetched[:len(self.outputs)]

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonclientsession.py in __call__(self, *args, **kwargs)
    1437 ret = tf_session.TF_SessionRunCallable(
    1438 self._session._session, self._handle, args, status,
    -> 1439 run_metadata_ptr)
    1440 if run_metadata:
    1441 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonframeworkerrors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
    526 None, None,
    527 compat.as_text(c_api.TF_Message(self.status.status)),
    –> 528 c_api.TF_GetCode(self.status.status))
    529 # Delete the underlying status object from memory otherwise it stays alive
    530 # as there is a reference to status from this from the traceback due to

    UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
    [[{{node conv2d_4/Conv2D}} = Conv2D[T=DT_FLOAT, _class=[“loc:@training_1/Adam/gradients/conv2d_4/Conv2D_grad/Conv2DBackpropFilter”], data_format=”NCHW”, dilations=[1, 1, 1, 1], padding=”VALID”, strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device=”/job:localhost/replica:0/task:0/device:GPU:0″](training_1/Adam/gradients/conv2d_4/Conv2D_grad/Conv2DBackpropFilter-0-TransposeNHWCToNCHW-LayoutOptimizer, conv2d_4/Conv2D/ReadVariableOp)]]
    [[{{node loss_2/activation_8_loss/broadcast_weights/assert_broadcastable/AssertGuard/Assert/Switch/_251}} = _Recv[client_terminated=false, recv_device=”/job:localhost/replica:0/task:0/device:CPU:0″, send_device=”/job:localhost/replica:0/task:0/device:GPU:0″, send_device_incarnation=1, tensor_name=”edge_321_l…ert/Switch”, tensor_type=DT_BOOL, _device=”/job:localhost/replica:0/task:0/device:CPU:0″]()]]

    Reply
  81. Chung Yau Ong on

    HELP

    Train on 17462 samples, validate on 7484 samples
    Epoch 1/3
    —————————————————————————
    UnknownError Traceback (most recent call last)
    in
    28 metrics=[‘accuracy’])
    29
    —> 30 model.fit(x, y, batch_size=32, epochs=3, validation_split=0.3)

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonkerasenginetraining.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, max_queue_size, workers, use_multiprocessing, **kwargs)
    1637 initial_epoch=initial_epoch,
    1638 steps_per_epoch=steps_per_epoch,
    -> 1639 validation_steps=validation_steps)
    1640
    1641 def evaluate(self,

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonkerasenginetraining_arrays.py in fit_loop(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps)
    213 ins_batch[i] = ins_batch[i].toarray()
    214
    –> 215 outs = f(ins_batch)
    216 if not isinstance(outs, list):
    217 outs = [outs]

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonkerasbackend.py in __call__(self, inputs)
    2984
    2985 fetched = self._callable_fn(*array_vals,
    -> 2986 run_metadata=self.run_metadata)
    2987 self._call_fetch_callbacks(fetched[-len(self._fetches):])
    2988 return fetched[:len(self.outputs)]

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonclientsession.py in __call__(self, *args, **kwargs)
    1437 ret = tf_session.TF_SessionRunCallable(
    1438 self._session._session, self._handle, args, status,
    -> 1439 run_metadata_ptr)
    1440 if run_metadata:
    1441 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

    ~Anaconda3envsics_fyplibsite-packagestensorflowpythonframeworkerrors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
    526 None, None,
    527 compat.as_text(c_api.TF_Message(self.status.status)),
    –> 528 c_api.TF_GetCode(self.status.status))
    529 # Delete the underlying status object from memory otherwise it stays alive
    530 # as there is a reference to status from this from the traceback due to

    UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
    [[{{node conv2d_4/Conv2D}} = Conv2D[T=DT_FLOAT, _class=[“loc:@training_1/Adam/gradients/conv2d_4/Conv2D_grad/Conv2DBackpropFilter”], data_format=”NCHW”, dilations=[1, 1, 1, 1], padding=”VALID”, strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device=”/job:localhost/replica:0/task:0/device:GPU:0″](training_1/Adam/gradients/conv2d_4/Conv2D_grad/Conv2DBackpropFilter-0-TransposeNHWCToNCHW-LayoutOptimizer, conv2d_4/Conv2D/ReadVariableOp)]]
    [[{{node loss_2/activation_8_loss/broadcast_weights/assert_broadcastable/AssertGuard/Assert/Switch/_251}} = _Recv[client_terminated=false, recv_device=”/job:localhost/replica:0/task:0/device:CPU:0″, send_device=”/job:localhost/replica:0/task:0/device:GPU:0″, send_device_incarnation=1, tensor_name=”edge_321_l…ert/Switch”, tensor_type=DT_BOOL, _device=”/job:localhost/replica:0/task:0/device:CPU:0″]()]]

    Reply
  82. Francisco Resende on

    I have this error: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    Someonde knows why??

    Reply
  83. Ashvni Kumar on

    Traceback (most recent call last):
    File “path”, line 31, in
    model.fit(X, y, batch_size=12, epochs=1, validation_split=0.3)
    File “”path” line 1536, in fit
    validation_split=validation_split)
    File “pathvenvlibsite-packagestensorflowpythonkerasenginetraining.py”, line 992, in _standardize_user_data
    class_weight, batch_size)
    File “pathvenvlibsite-packagestensorflowpythonkerasenginetraining.py”, line 1154, in _standardize_weights
    exception_prefix=’target’)
    File “pathvenvlibsite-packagestensorflowpythonkerasenginetraining_utils.py”, line 284, in standardize_input_data
    data = [standardize_single_array(x) for x in data]
    File “pathvenvlibsite-packagestensorflowpythonkerasenginetraining_utils.py”, line 284, in data = [standardize_single_array(x) for x in data]
    File “pathvenvlibsite-packagestensorflowpythonkerasenginetraining_utils.py”, line 218, in standardize_single_array
    if x.shape is not None and len(x.shape) == 1:
    AttributeError: ‘str’ object has no attribute ‘shape’

    Reply
  84. Ashvni Kumar on

    i am using for different dataset but i am caught at this error. Help me.
    My dataset has total 4000 images in 4 classes, 1000 images in each class.

    ValueError: Input arrays should have the same number of samples as target arrays. Found 40 input samples and 4000 target samples.

    Reply
  85. shehab el deen aymen on

    so when i use a data set i just got off of the internet in the training part i get this error
    Please provide as model targets either a single array or a list of arrays . You passed: y=[0, 0, 1, 0, 0, 0, 0, 1, 0,…]

    Reply
  86. bale on

    Guys i just wanna know whether i am the only one who couldn’t understand sentdex tutorials on the first run but as i go through many other basic videos and come back – i get it pretty good

    Reply
  87. Scott K on

    was getting an cuDNN failed to initialise error. anyone getting this as well? or know how to go around it?

    [Edit] solved it. Thank you! Great video

    Reply
  88. Derick A. Ho on

    Do you have a tutorial where you implement faster RCNN for object detection? I want to learn how to make one using the CNN made from scratch. I am aware of the tensorflow object detection api but it doesn’t help me learn how to create my own model.

    Reply
  89. Sumair Hassan on

    —————————————————————————
    FileNotFoundError Traceback (most recent call last)
    in
    4 import pickle
    5
    —-> 6 X = pickle.load(open(“X.pickle”, “rb”))
    7 y = pickle.load(open(“y.pickle”, “rb”))
    8

    FileNotFoundError: [Errno 2] No such file or directory: ‘X.pickle’

    Can someone guide me how to reaolve this error?

    Reply
  90. Shubham Gupta Ggps on

    getting error
    ValueError: Input arrays should have the same number of samples as target arrays. Found 74838 input samples and 24946 target samples.

    Reply
  91. payne max on

    python are just so amazing! i mean its just so friendly to use,u can just grab some tool and go ahead,play with it,and its fun!

    Reply
  92. Sourin Roy on

    FileNotFoundError: [Errno 2] No such file or directory: ‘X.pickle’

    Hi I’m getting this error , could anyone help please?

    Reply
  93. Amanogawa Saori on

    Hi, I’m facing an error when I wrote the same program:
    —> model.add(Conv2D(64, (3, 3), input_shape=X.shape[1:]))
    ValueError: Input 0 of layer conv2d is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [None, 128, 128]
    Thanks in advance.

    Reply
  94. Hurley Wales on

    I kept getting a value error “can process an array or list of arrays” which was solved by turning the y variable into a numpy array. In case anyone else has this problem.

    Reply
  95. Iva Georgieva on

    Hello,
    Did you use Anaconda for using those libraries? I am a beginner with Python and I can’t get Sequential, Dense etc to work even though I have installed them. Did anyone have the same problem?
    Thank you!

    Reply
  96. Suyog Nepal on

    i am getting this error plz help me community

    Error when checking target: expected dense_11 to have 2 dimensions, but got array with shape (24943, 50, 50, 1)

    Reply
  97. shabnam pathan on

    I am newbie to machine learning.i am following your tutorials.I successfully able to load dataset but now I am stuck in running convolutional model
    It is giving error
    TypeError:TF_Session_wrapper:expected all values in input dict to be ndarray.

    Just to check if tenserflow is working or not I did some addition multiplication

    So it worked successfully.
    But when I use
    Print(sess.run(y,feed_dict={x,:[3,5]})))
    This also gives same TypeError.

    Does anyone know what is the problem?

    Reply
  98. Rana Osama on

    TypeError: Input ‘y’ of ‘Equal’ Op has type float32 that does not match type int32 of argument ‘x’. this error appear when i try the code

    Reply
  99. Harijs Ijabs on

    Hey! Very useful and comprehensive series so far! You got my sub!
    Question – how would you go about implementing multispectral imagery (i.e. – more than 3 bands) ?

    Reply
  100. Kaushil Kundalia on

    I am getting an error on the “model.fit()” statement. Error is: “ValueError: Error when checking input: expected conv2d_10_input to have 4 dimensions, but got array with shape (24946, 50, 50)
    “. Any help would be appreciated ^_^. Thank you

    Reply
  101. Samkit Kundalia on

    If you want to see a flowchart of your model, use:
    from keras.utils import plot_model
    plot_model( model, ‘Chart.png’ )

    Reply
  102. vidya kurada on

    Hi nicely done. What if my output (y) is also an image. And I want to run an image regression. Please do comment.

    Reply
  103. c w on

    was this done with an older version? i cant even import any of those
    from tensorflow.keras.models import Sequential doesnt work

    Reply
  104. sapo mol on

    i get error in X = pickle.load(open(“X.pickle”,”rb”))
    X = pickle.load(open(“X.pickle”,”rb”))
    FileNotFoundError: [Errno 2] No such file or directory: ‘X.pickle’
    help please .

    Reply
  105. Asif Moin Qureshi on

    —————————————————————————
    FileNotFoundError Traceback (most recent call last)
    in
    8 import pickle as pickle
    9
    —> 10 pickle_in = open(“X.pickle”,”rb”)
    11 X = pickle.load(pickle_in)
    12

    FileNotFoundError: [Errno 2] No such file or directory: ‘X.pickle’

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons