Thank you Dr. Rai for the video. Very helpful. :) I am going back and forth to the different sections, so I thought I would add the time stamps below. I hope you like it and it is also helpful to others. Load Packages at 0:02 Read Images at 0:29 Explore at 4:08 Resize at 6:16 Reshape at 7:23 Row Bind at 8:45 One Hot Encoding at 11:49 Create Model at 12:42 Compile at 16:02 Fit Model at 16:38 Evaluation and Prediction (train data) at 18:49 Evaluation and Prediction (test data) at 22:20 True or False questions at 23:46
Thanks for all ur effort. With this code u can get 100% accuracy Sir. # Compiling model model %>% keras::compile(loss = 'binary_crossentropy', optimizer = 'adam', metrics = 'accuracy') # Ajusting model history % fit(trainx, trainLabels, epochs = 15 batch_size = 32, validation_split = 0.2) plot(history)
Sir, Iam getting an error when fitting model (16:38) " ValueError: Dimensions must be equal, but are 4 and 2 for '{{node binary_crossentropy/mul}} ". Iam using this for a data set of say 5 records . 3 training and 2 testng records where variable to be predicted is binary ( has values 0 to 4). ANy insights on which dimensions could be incorrect?
Thank you Dr Rai. I am a beginner with treatment of image. I have a problem with array-reshape. This function stop the execution of the line. I have charge TensorFlow, Keras KerasR, reticulate. I also try using aperm without success. Could you help me ?
Once completed with training and testing, how to predict a new image? is this corrected: model %>% predict_classes("link_newimage.jpg") ? Do we need to resize and reshape the new image before prediction? I faced several error regarding this step. i.e, Error in py_call_impl(callable, dots$args, dots$keywords)
I do not understand the section on how to create populations for cars and planes 1 through 6 and then stored in what form so that when called "setwd" runs. Please help sir,thank you...
@Bharatendra Rai, you succeeded in making CNN very cool... thanks for the video. I followed the example and trust me i watch all the video several times just to get a hang of it. I feel you're the only one that has gone to lenght to explains what is actually happening in the layers. thanks for this. I have set of images from geology (1325 in total) belonging to 102 classes (groups). i was wondering how to handle this because physically typing the labels and dividing into test and train would take me forever. I was wondering if can recommend an easy way to handle this large data and read them in.
Thanks for comments! For reading several images you can refer to this link where all files in a folder are read easily: ua-cam.com/video/5bso_5X7Zu4/v-deo.html
thank you for your tutorial. It works perfectly, however, when I increase the resolution of the pictures you provided (50x50, 75x75, etc...) it doesnt seem to work. I have changes the resolution in both resize and reshape. When I use resolution similar to the one you provided (29x29 or 27x27) it does seem to work (it says the accurary is 0.5, flipping a coin, esencially). How is this possible?
i am getting the following error.. please help ERROR: dependencies 'jsonlite', 'reticulate' are not available for package 'tensorflow' * removing 'C:/Users/dell/Documents/R/win-library/3.5/tensorflow' In R CMD INSTALL Installation failed: Command failed (1)
Dear Dr Rai Many thanks this is very helpful. However if when I tried to replicate your example I get error for the history object and consequently on the "evaluation and prediction" because there is an issue with py_call_impl(callable, dots$args, dors$keywords): input arrays should have the same number of samples as target arrays. Found 5 input samples and 10 target samples. Any cues to solve this? Thanks!
Many thanks! I solved and I managed to run the script however sometimes I ve got issue with 1 0 coding. If I check the predicted actual matrix I gives me, apparently randomly, only one row(ie accuracy is 50% cause predict only one class). Any clues? Best Regards!
Awesome tutorial Dr. Rai. Thank you. It was inspire me a lot. Today I have tried to follow, but I am still facing problem --> Error: Python module tensorflow.keras was not found. I have try to re-install tensorflow and karas, but still same.
Thank you so much for a great tutorial! I am currently working with a large dataset of images (around 30,000 images). How could I make a list like you did under 'pics' easily without listing all of the filenames? Thank you!
Hello... I'm back with a serious problem. I cannot use the array_reshape function. First, I had to install the retculate package, because the program told me that this function is part of the reticulate package, not keras (??). But even after installing reticulate, I got the following error for when executed the array_reshape function: Error in py_call_impl(callable, dots$args, dots$keywords) : Evaluation error: Required version of NumPy not available: numpy.core.multiarray failed to import. What could that be? Thank you very much!
I'm getting below error while reading the images- Error in readJPEG(x, ...) : JPEG decompression error: Not a JPEG file: starts with 0x89 0x50 As I have all the images in JPEG format but when I used the image_read() function from the magick package, I found that some of the images having PNG format. So, How to find all those images where there is a change in extension? Also, how to convert these type of images in pixel format?
to_categorical is throwing an error for me "Error in install_tensorflow() : could not find function "install_tensorflow". Can you let me know how to proceed ?
Professor Bharatendra, I would like to inquire you how can I put another kind of metric, namely, log loss function or another one. This is due to metrics=c("categorical_accuracy") is not working very well and it seems that I obtained for a multiclass problem an imbalanced classes problem for a set of images with the same quantity of elements for each class. Thank you in advance for your answer.
sir while executing to_categorial function of keras library i am getting error as pythan module keras not found. but i have installed keras library in R already. so plz give me solution over it.
Hi. first of all, than kyou for making this video. While I was following the steps, mine keep making error when doing "Reshape". It says 'dll load failed'. I thought there was a problem with keras, so I re-installed it thousand times and it never works. please help me...I have no time for my work...I'm hoping your fast respond. Thank you
Great tutorial.. but having a lot of issues with memory. After trying to train the model I get 'Error in py_call_impl(callable, dots$args, dots$keywords): ResourceExhaustedError: OOM when allocating tensor...' Anyone else have this issue or know how to solve it?
@@bkrai sir I have runned keras in separate sessionR also,but it again showing Python.keras not found nd sometime it showing to_categorical function not found
Thankyou so much for the tutorial. It really help me understand about Keras in R. But, while i'm trying to practicing the code, i got an error on fit model. The error is " Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: Error when checking target: expected dense_3 to have shape (2,) but got array with shape (1,)" can you help me to understand the problem? Thanyou so much!
Try this, worked for me. :) -- Install these: install.packages("BiocManager") BiocManager::install("EBImage") #EBImage isn't supported in latest R, so this... install.packages("keras") install.packages("tensorflow") library("EBImage") library("keras") library("tensorflow") install_tensorflow() #install for to_categorical() -- After installation is complete, it shows restarting session and gets stuck there... Manually restart RStudio, load those three libraries and run the rest of the code. Also, alternatives to to_categorical: Package CatEncoders, OneHotEncoder (same as Python scikit-learn). Package caret, function dummyVars.
When I try using #Reshape I get this error: Error in initialize_python(required_module, use_environment) : Installation of Python not found, Python bindings not loaded.
Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: A target array with shape (10, 1) was passed for an output of shape (None, 2) while using as loss `binary_crossentropy`. This loss expects targets to have the same shape as the output
Unfortunately, it does not work. The keras_model_sequential function does not work. It gives an error: the module keras.tensorflow was not found. I have tried everything: the functions install_keras(), instal_tensorflow() and so on - no result. Please tell me, there are some technical conditions that you don't specify in the video? Do you need to have installed Anaconda, Python?... Which versions? I have installed Anaconda, tried to activate the environment etc. etc. but useless. it seems that I cannot make keras work on my machine. Could someone help? Thanks.
@@bkrai yes I already followed your videos as I understand : 1-Load Data. 2-Define Keras Model. 3-Compile Keras Model. 4-Fit Keras Model. 5-Evaluate Keras Model. 6-Tie It All Together. 7-Make Predictions
Sir I have a request please do a video on Naive Bayes classifier on any data and please also teach little theory before the video so we can understand it and explain it to others. Thank you sir.
how can this code be modified to classify more than 2 categories of images? Like, I have 6 classes of images and need to classify any new image to be among any 1 of the 6 categories. Also, I am not able to use the keras package as it is showing me "Error: Python module keras was not found." whereas I have it installed in my python environment. Can you help me in this as i need to understand this code and work on my thesis? Thankyou
Hii sir. I understood everything u said in this vedio thank u nice vedio sir But how can we update this for multi class image classification Once again thank u
Hii sir, display(mypic[[1]]) Error in UseMethod("display", x) : no applicable method for 'display' applied to an object of class "c('Image', 'array', 'structure', 'vector')"
@@uchekalu7725 Hello, thanks for help. Here is my related code: " #evaluation & prediction -traindata model %>% evaluate(trainx, trainLabels) pred % predict(trainx) %>% k_argmax() #pred % predict(trainx) pred table(Predicted = pred, Actual = trainy) prob % predict(trainx)#prob % predict_proba(trainx) #prob % predict() prob cbind(prob, Prected = pred, Actual= trainy) " could you write the correct code?
@bharatendra rai sir, I am getting an error: > history % + fit(trainx, + trainLabels, + epochs = 30, + batch_size = 32, + validation_split = 0.2) Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: Input arrays should have the same number of samples as target arrays. Found 5 input samples and 10 target samples.
This also looks right. Next I would suggest check line-27 from the video. Note that first I read 1 to 5 pictures and then from 7 to 11. This way there were totally "10 input samples".
Thank you, sir, for this video I did it based on your code but it gives me 50% accuracy with exactly the same code you post in the video, how this coming? how can we re-modify the model to reach the best accuracy?
I got a problem with array_reshape, it tell me getting error Error in initialize_python(required_module, use_environment) : Installation of Python not found, Python bindings not loaded. I run keras and I run EBImage but the problem is still there im trying to reach you and send you my codes, but I couldn't find ur contact.
keras package that I used in the video is version 2.1.2. The one you installed is version 1.2.0 which is too old. I would suggest you install it again.
It is really a pain to get tensorflow running on rstudio. First you have to install tensorflow on anaconda (there guides for it on youtube) and then on rstudio. (that worked for me)
Awesome video, Thank you. I still cannot install EBImage :( Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘EBImage’
when i run the code, the following error occur. > model %>% + layer_dense(units = 256, activation = 'relu', input_shape = c(2352)) %>% + + layer_dense(units = 128, activation = 'relu') %>% + + layer_dense(units = 2, activation = 'softmax') Error in eval(lhs, parent, parent) : object 'model' not found > summary(model) Error in summary(model) : object 'model' not found can you help me?
hi I am getting the following error. kindly suggest the solution> pred % predict_classes(trainx) Error in py_call_impl(callable, dots$args, dots$keywords) : TypeError: float() argument must be a string or a number, not 'NoneType'
i have just follow your tutrial amd retrain your data but i got error on fitting model...as follows Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: in user code: File "C:\Users\LENOVO\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\keras\engine\training.py", line 1021, in train_function * return step_function(self, iterator) please help me to complete my trial...thanks
Dear Mr Bharatendra, thank you for the awesome video! I am getting the same results of Mr Kumar thought... I tried to review the code but was unable to find any mistakes. The model always predicts car! Actual Predicted 0 1 0 5 5 the histogram does not display an initial variation in the training and a posterior stabilization. The plot is stable in the same probability since the beginning!? Can you offer some insights in what is happening? I had some problems installing EBImage in the 3.5 R.
Hello, first of all thank you for making this tutorial! I am very new to R and machine learning, and this tutorial has really helped me to understand each of the steps. I am however coming up against an error regarding the input, and wondered if you had and suggestions? when I use: history % fit(trainx, trainLabels, epochs = 30, batch_size = 32, validation_split = 0.2) I get this error: ValueError: Input 0 of layer sequential_10 is incompatible with the layer: expected axis -1 of input shape to have value 2352 but received input with shape [None, 20, 1] *'sequential_10' is the name of the model in Kaggle I believe For some reason I wasn't able to get tensorflow to work in R on my laptop (despite trying lots of different methods for 2 weeks), and so I am using a combination of R and a Kaggle Notebook using R script. I am doing the first steps (importing images, reshaping, binding) in R, then exporting 'trainx' and 'testx' as csv files, then loading those into Kaggle... is this where I am going wrong? I am using planes vs cars images, and I don't see any errors in the previous lines of code. Searching this error online hasn't proved to solve the situation yet either
This prof made me love R..he made me understand machine learning in a very simplified way..I shall forever stay grateful
Thanks for your nice comments!
Thank you Dr. Rai for the video. Very helpful. :)
I am going back and forth to the different sections, so I thought I would add the time stamps below.
I hope you like it and it is also helpful to others.
Load Packages at 0:02
Read Images at 0:29
Explore at 4:08
Resize at 6:16
Reshape at 7:23
Row Bind at 8:45
One Hot Encoding at 11:49
Create Model at 12:42
Compile at 16:02
Fit Model at 16:38
Evaluation and Prediction (train data) at 18:49
Evaluation and Prediction (test data) at 22:20
True or False questions at 23:46
Thanks Caroline! I've added it to description area below this video.
Awesome tutorial sir, you are going deeper into R and I just love it. Please keep making videos we really need you. Thank you so much.
Thanks!
There r intimidating topics like deep learning that I never wanted to touch...today,thanks to you, I am a pro.
Excellent!
Nice Tutorial. Small Edit, you can read multiple files by the following command,
pics
Thanks for the suggestion!
Thank you! Wish you and your family stay well through this calamity.
Thanks and best wishes to you and family too!
Thank you very much Dr. Rai for all the effort in creating these very helpful tutorials.
Thanks for your comments!
Thanks for all ur effort. With this code u can get 100% accuracy Sir.
# Compiling model
model %>%
keras::compile(loss = 'binary_crossentropy',
optimizer = 'adam',
metrics = 'accuracy')
# Ajusting model
history %
fit(trainx,
trainLabels,
epochs = 15
batch_size = 32,
validation_split = 0.2)
plot(history)
Yes, it is relatively small data.
FANTASTIC! Thanks for providing such stuff for free. Really appreciate.
Amazing tutorial. Thank you so much for making this available to us .
You're very welcome!
Sir, Iam getting an error when fitting model (16:38) " ValueError: Dimensions must be equal, but are 4 and 2 for '{{node binary_crossentropy/mul}} ". Iam using this for a data set of say 5 records . 3 training and 2 testng records where variable to be predicted is binary ( has values 0 to 4). ANy insights on which dimensions could be incorrect?
If your response has values from 0 to 4, it will be incorrect to use binary. Binary is for response with only 2 values.
Oh I see...then how do we perform model and classification for this kind sir?
For more than 2 classes you can refer to this:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
@@bkrai Thank you Sir..I will use this for my images and check
Thanks for the update!
running that code "for(i in 1:12) {mypic[[i]]
Make sure you run library(keras) after installing keras package.
getting this error now , Error in py_module_import(module, convert = convert) :
ModuleNotFoundError: No module named 'numpy
Thank you so much for the tutorial, very good example.
Thanks for comments!
what about transforming the images with 3 channels into grey images : the length of flatten input is reduced and may be performance
Awesome tutorial! But I got stuck at min 12:31 because R tells me: Error in to_categorical(testy) : could not find function "to_categorical"
See if this helps:
ua-cam.com/video/-IYYqdxdYXk/v-deo.html
Thanks for the great tutorial. Can I use Keras for identifying tree species just using leaf? How do I separate the image of leaf from the background?
Yes, you can. Note that you will have to prepare images beforehand.
@@bkrai how to prepare those images using R? Is there a package that could seperate the background and the item that I want to identify? Thanks a lot.
I'll look into it.
thanku sir very good explaination ...plz make videos on NLP as well
For text data related videos, refer to:
studio.ua-cam.com/users/playlistPL34t5iLfZddt0tt5GdDy3ny6X5RQvwrp6/edit
Your videos are very informative👍, you could have used list.files and any of the apply list of functions to import multiple files
Thanks for the suggestion! For importing multiple files you can also refer to:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
Sir Iam getting an error while reading pics to my pic at the line for(i in 1:12){my pic[[i]]
Check the folder where you have pictures and make sure it only has pictures.
@@bkrai tq sir it solved ..I have not mention file format for the pic names ..tq sir
Thank you Dr Rai.
I am a beginner with treatment of image. I have a problem with array-reshape. This function stop the execution of the line. I have charge TensorFlow, Keras KerasR, reticulate. I also try using aperm without success. Could you help me ?
Very useful and informative, sir. Thank you!
Thanks for comments!
Excellent tutorial. Please i have issues installing EBImage package on my R 3.6.0 version. Any suggestions?
Try this:
To install EBimage package, you can run following 2 lines;
install.packages("BiocManager")
BiocManager::install("EBImage")
Dear Sir, Can you prepare a tutorial on the whole slide image analysis. That will be more beneficial.
Thanks, I've added this to my list.
thanks for the tutorial! greetints from brazil
You are welcome!
Thanks so much, Sir. Can you make videos about using R with U-Net for semantic segmentation?
Once completed with training and testing, how to predict a new image? is this corrected: model %>% predict_classes("link_newimage.jpg") ? Do we need to resize and reshape the new image before prediction? I faced several error regarding this step. i.e, Error in py_call_impl(callable, dots$args, dots$keywords)
please make a video on how to use the shiny package to develop an app for sentimental anaysis
Thanks for the suggestion, I've added it to my list.
I do not understand the section on how to create populations for cars and planes 1 through 6 and then stored in what form so that when called "setwd" runs. Please help sir,thank you...
See if this link helps answer your question where we read several image files:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
Any suggestion of visualizing convolutional neural networks filter and model graph based Keras in R Studop platform?
Thanks for bringing this up, I'll look into this.
@Bharatendra Rai, you succeeded in making CNN very cool... thanks for the video. I followed the example and trust me i watch all the video several times just to get a hang of it. I feel you're the only one that has gone to lenght to explains what is actually happening in the layers. thanks for this.
I have set of images from geology (1325 in total) belonging to 102 classes (groups). i was wondering how to handle this because physically typing the labels and dividing into test and train would take me forever. I was wondering if can recommend an easy way to handle this large data and read them in.
Thanks for comments!
For reading several images you can refer to this link where all files in a folder are read easily:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
Sir, why did you used 28 for resizing ? What other sizescan be used for best result? On what basis do we choose the size?
Since this is just for illustration, I used small size so that it runs faster. But there is no such requirement, you can use any other size.
@@bkrai Okay Thanks!
thank you for your tutorial. It works perfectly, however, when I increase the resolution of the pictures you provided (50x50, 75x75, etc...) it doesnt seem to work. I have changes the resolution in both resize and reshape. When I use resolution similar to the one you provided (29x29 or 27x27) it does seem to work (it says the accurary is 0.5, flipping a coin, esencially). How is this possible?
Make sure training data do not have same type of images in a sequence.
When I try to use *array_reshape* in
# Reshape
for (i in 1:12) {mypic[[i]]
Thanks for the update!
Bharatendra Rai
I should thank you for your videos
i am getting the following error.. please help
ERROR: dependencies 'jsonlite', 'reticulate' are not available for package 'tensorflow'
* removing 'C:/Users/dell/Documents/R/win-library/3.5/tensorflow'
In R CMD INSTALL
Installation failed: Command failed (1)
Awesome !!! Can this be used to discern between two types of fish?
Yes, definitely
Dear Dr Rai
Many thanks this is very helpful. However if when I tried to replicate your example I get error for the history object and consequently on the "evaluation and prediction" because there is an issue with py_call_impl(callable, dots$args, dors$keywords): input arrays should have the same number of samples as target arrays. Found 5 input samples and 10 target samples.
Any cues to solve this?
Thanks!
There is a mismatch between target values (10 data points) and input (5 data points).
Many thanks! I solved and I managed to run the script however sometimes I ve got issue with 1 0 coding. If I check the predicted actual matrix I gives me, apparently randomly, only one row(ie accuracy is 50% cause predict only one class). Any clues? Best Regards!
Awesome tutorial Dr. Rai. Thank you. It was inspire me a lot. Today I have tried to follow, but I am still facing problem --> Error: Python module tensorflow.keras was not found. I have try to re-install tensorflow and karas, but still same.
If you are using Mac, try this:
ua-cam.com/video/-IYYqdxdYXk/v-deo.html
Hi is there any possibility to use more than just one variable as output in this or other NN packages?
Hello Sir,
Its a really nice tutorial. Can you please tell me what do we do for a multiple image classification problem??
Thanks
This tutorial is for one image in a picture only.
Thank you .
Btw, If we have for example more than 12 pictures, ( consider 5000), then how we can assign them in pics?
pics
You can refer to this for reading any number of image files from a folder:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
Does mypic need to be a list? Can we define it as a data frame as well? Thanks.
I've not tried, but see if it works.
Thank you so much for a great tutorial! I am currently working with a large dataset of images (around 30,000 images). How could I make a list like you did under 'pics' easily without listing all of the filenames? Thank you!
You can find an example here:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
Hi Rai
Can you also make a video about h2o package.. espacially for the automl function.. and share your comments about if it is succesfull or not
Thanks for the suggestion! I have added it to my list.
Sir, after the command
trainLabels
I don't see any error in this specific line. Probably error is somewhere earlier and the effect is seen here.
Hello... I'm back with a serious problem. I cannot use the array_reshape function. First, I had to install the retculate package, because the program told me that this function is part of the reticulate package, not keras (??). But even after installing reticulate, I got the following error for when executed the array_reshape function:
Error in py_call_impl(callable, dots$args, dots$keywords) :
Evaluation error: Required version of NumPy not available: numpy.core.multiarray failed to import.
What could that be? Thank you very much!
Probably try this:
ua-cam.com/video/-IYYqdxdYXk/v-deo.html
I'm getting below error while reading the images-
Error in readJPEG(x, ...) :
JPEG decompression error: Not a JPEG file: starts with 0x89 0x50
As I have all the images in JPEG format but when I used the image_read() function from the magick package, I found that some of the images having PNG format.
So, How to find all those images where there is a change in extension? Also, how to convert these type of images in pixel format?
to_categorical is throwing an error for me "Error in install_tensorflow() :
could not find function "install_tensorflow". Can you let me know how to proceed ?
You can try this:
ua-cam.com/video/-IYYqdxdYXk/v-deo.html
Professor Bharatendra, I would like to inquire you how can I put another kind of metric, namely, log loss function or another one. This is due to metrics=c("categorical_accuracy") is not working very well and it seems that I obtained for a multiclass problem an imbalanced classes problem for a set of images with the same quantity of elements for each class. Thank you in advance for your answer.
Did you try: metrics = c('accuracy')
Good job. Really Appreciated.
Thanks for comments!
sir while executing to_categorial function of keras library i am getting error as pythan module keras not found. but i have installed keras library in R already. so plz give me solution over it.
Make sure after installing you also run the library line.
Sir, after the command
trainLabels
I would suggest to download and install 64bit version of R.
another great tutorial, thank you.
Thanks for comments!
excellet tutorial. I was wondering how can you make a class activation map (heatmap) from the tutorial you just made.
Hi. first of all, than kyou for making this video. While I was following the steps, mine keep making error when doing "Reshape". It says 'dll load failed'. I thought there was a problem with keras, so I re-installed it thousand times and it never works. please help me...I have no time for my work...I'm hoping your fast respond. Thank you
Can I know which model is used
It's MLP.
@@bkrai tqs ,sir what if there are 4 different images to classify then how to label with binary values
This link has 10 different images:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
Great tutorial.. but having a lot of issues with memory. After trying to train the model I get 'Error in py_call_impl(callable, dots$args, dots$keywords): ResourceExhaustedError: OOM when allocating tensor...' Anyone else have this issue or know how to solve it?
If you already have any data or similar file open that you are not using, I would suggest close it and try again.
what can i use as a binary_crossentropy? I have 4 response variables. It's urgent please help.
categorical_crossentropy()
You can also refer to this:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
Sir Iam getting the error at encoding that is Error in to_categorical(trainy):could not find function to_categorical
Make sure you have run library(keras).
@@bkrai sir I have runned keras in separate sessionR also,but it again showing Python.keras not found nd sometime it showing to_categorical function not found
That means keras is not installed.
@@bkrai k tq sir..I want small information sir..is there any package to open our webcam?.how to take pics and then compare it in r language ..
Thankyou so much for the tutorial. It really help me understand about Keras in R. But, while i'm trying to practicing the code, i got an error on fit model. The error is " Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: Error when checking target: expected dense_3 to have shape (2,) but got array with shape (1,)" can you help me to understand the problem? Thanyou so much!
I saw your message now. I hope by now you figured it out.
Sir..I am getting an error in the function "to_categorical" saying that it could not find the function
Try this, worked for me. :)
-- Install these:
install.packages("BiocManager")
BiocManager::install("EBImage") #EBImage isn't supported in latest R, so this...
install.packages("keras")
install.packages("tensorflow")
library("EBImage")
library("keras")
library("tensorflow")
install_tensorflow() #install for to_categorical()
-- After installation is complete, it shows restarting session and gets stuck there... Manually restart RStudio, load those three libraries and run the rest of the code.
Also, alternatives to to_categorical:
Package CatEncoders, OneHotEncoder (same as Python scikit-learn).
Package caret, function dummyVars.
Thanks for the update!
@@BilalHussain-md2ch I have tried your method but it still doesn't work:
Error: Python module tensorflow.keras was not found.
Detected Python configuration:
python: C:/Users/b145065/AppData/Local/r-miniconda/envs/r-reticulate/python.exe
libpython: C:/Users/b145065/AppData/Local/r-miniconda/envs/r-reticulate/python36.dll
pythonhome: C:/Users/b145065/AppData/Local/r-miniconda/envs/r-reticulate
version: 3.6.12 |Anaconda, Inc.| (default, Sep 9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/b145065/AppData/Local/r-miniconda/envs/r-reticulate/Lib/site-packages/numpy
numpy_version: 1.19.1
@@Felixinhk08 You need to run this line and then restart R, then take the line out and try it :) :
install_tensorflow()
Well, EBImage is not available anymore so .. :/
Codes for installing EBImage should be there in the description area.
@@bkrai You are correct. It worked great, much appreciated Dr Rai!
Thanks for the update!
When I try using #Reshape
I get this error: Error in initialize_python(required_module, use_environment) :
Installation of Python not found, Python bindings not loaded.
you must be install Anaconda and run rstudio form there. Check this link :github.com/rstudio/keras/issues/649
Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: A target array with shape (10, 1) was passed for an output of shape (None, 2) while using as loss `binary_crossentropy`. This loss expects targets to have the same shape as the output
Instead of using binary, I got multiple categories, which loss function should I use?
You can refer to this where we have 10 categories:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
Unfortunately, it does not work. The keras_model_sequential function does not work. It gives an error: the module keras.tensorflow was not found. I have tried everything: the functions install_keras(), instal_tensorflow() and so on - no result. Please tell me, there are some technical conditions that you don't specify in the video? Do you need to have installed Anaconda, Python?... Which versions? I have installed Anaconda, tried to activate the environment etc. etc. but useless. it seems that I cannot make keras work on my machine. Could someone help? Thanks.
Check this link:
ua-cam.com/video/-IYYqdxdYXk/v-deo.html
Sir , PLease I have one question : deep Learning Process in r I mean if you want to case study whats it the process , step by step
You can find some case studies here:
ua-cam.com/play/PL34t5iLfZddtC6LqEfalIBhQGSZX77bOn.html
@@bkrai yes I already followed your videos as I understand :
1-Load Data.
2-Define Keras Model.
3-Compile Keras Model.
4-Fit Keras Model.
5-Evaluate Keras Model.
6-Tie It All Together.
7-Make Predictions
Perfect!
I don't understand why the batch size is 32? What does it mean?
Here the data is too small. If the batch size specified is larger than the data size, essentially all samples in the data will be used.
i am facing trouble loading tensorflow
any suggestions
Sir I have a request please do a video on Naive Bayes classifier on any data and please also teach little theory before the video so we can understand it and explain it to others. Thank you sir.
Thanks, it's on my list and I'll try to do it soon.
Thank you Sir
how can this code be modified to classify more than 2 categories of images? Like, I have 6 classes of images and need to classify any new image to be among any 1 of the 6 categories.
Also, I am not able to use the keras package as it is showing me "Error: Python module keras was not found." whereas I have it installed in my python environment.
Can you help me in this as i need to understand this code and work on my thesis?
Thankyou
You can try this link:
ua-cam.com/video/LxTDLEdetmI/v-deo.html
In addition for more complete coverage, you can use following playlist:
ua-cam.com/play/PL34t5iLfZddtC6LqEfalIBhQGSZX77bOn.html
Thank you Sir. Glad to study through your videos. Neural networks look like a piece of cake now.
Thanks for your comments!
Any idea why I am getting Error in transpose(y) : object is NULL when running for loop readImage(pics[i])
either u have not installed EBimage package or just execute library(EBimage) line before executing for loop.
Hii sir.
I understood everything u said in this vedio thank u nice vedio sir
But how can we update this for multi class image classification
Once again thank u
You can refer to this link for multi class:
ua-cam.com/video/5bso_5X7Zu4/v-deo.html
@@bkrai thank u sir
Welcome!
Sir the EBImage package is not coming for version 3.6..pls help me
To install EBimage package, you can run following 2 lines;
install.packages("BiocManager")
BiocManager::install("EBImage")
Hii sir,
display(mypic[[1]])
Error in UseMethod("display", x) :
no applicable method for 'display' applied to an object of class "c('Image', 'array', 'structure', 'vector')"
check if you ran EBImage library or not
Can u tell the code to read thousands of images using EBImage package instead of importing one by one? Thanks in advance sir.
Thanx for share Sir,
I am getting
"Error in unique.default(x, nmax = nmax) :
unique() applies only to vectors
"
What could be a solution for me sir?
Use pipe operator to add as.numeric() to k_argmax
As in
k_argmax %>% as.numeric()
@@uchekalu7725 Hello, thanks for help. Here is my related code:
"
#evaluation & prediction -traindata
model %>% evaluate(trainx, trainLabels)
pred % predict(trainx) %>% k_argmax() #pred % predict(trainx)
pred
table(Predicted = pred, Actual = trainy)
prob % predict(trainx)#prob % predict_proba(trainx) #prob % predict()
prob
cbind(prob, Prected = pred, Actual= trainy)
" could you write the correct code?
@@hapvideolar7957
#Evaluation: model %>% evaluate(trainx, trainLabels)
#Prediction: pred % predict(trainx) %>% k_argmax() %>% as.numeric()
#ConfusionMatrix: table(Predicted = pred, Actual = trainy)
prob % predict(trainx)
cbind(prob, Predicted = pred, Actual = trainy)
Hope this helps.
@@uchekalu7725 yes, thx. I had already solved thx 2 u that day you replied first.
It works out
@bharatendra rai sir, I am getting an error: > history %
+ fit(trainx,
+ trainLabels,
+ epochs = 30,
+ batch_size = 32,
+ validation_split = 0.2)
Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: Input arrays should have the same number of samples as target arrays. Found 5 input samples and 10 target samples.
It says "Found 5 input samples and 10 target samples." Make sure to use proper number of units.
@@bkrai proper number of units where exactly sir?
What codes have you used under # Model and # Compile?
@@bkrai # Model
model %
layer_dense(units = 256, activation = "relu", input_shape = c(2352)) %>%
layer_dense(units = 128, activation = 'relu') %>%
layer_dense(units = 2, activation = "softmax")
summary(model)
# Compile
model %>%
compile(loss = "binary_crossentropy",
optimizer = optimizer_rmsprop(),
metrics = c('accuracy'))
This also looks right.
Next I would suggest check line-27 from the video. Note that first I read 1 to 5 pictures and then from 7 to 11. This way there were totally "10 input samples".
I would like to train images against matrices as respponse variables, can you please help with the code
What kind of matrices are these?
A matrix containing single row and 6 columns.
Or can we train matirx against another matrix with both matrices containing [1 row * 6 columns]. Thanks
Thank you, sir, for this video I did it based on your code but it gives me 50% accuracy with exactly the same code you post in the video, how this coming? how can we re-modify the model to reach the best accuracy?
Use [sigmoid] instead of [softmax] in output layer. Worked for me.
@@woutertwo thanks sigmoid worked for me
i've problem with tensorflow, how to install tensorflow in R on macbook? Thank you sir
You can use following code:
install.packages("tensorflow")
library(tensorflow)
install_tensorflow()
any chance of updated version of this
I'm exploring updating this and other deep learning videos. Hopefully I'll be able to start later this month.
I got a problem with array_reshape, it tell me getting error Error in initialize_python(required_module, use_environment) :
Installation of Python not found, Python bindings not loaded.
I run keras and I run EBImage but the problem is still there
im trying to reach you and send you my codes, but I couldn't find ur contact.
Probably issue with keras installation. Try this link before image recognition video:
ua-cam.com/video/hd81EH1g1bE/v-deo.html
when i use: trainLabels
keras package that I used in the video is version 2.1.2. The one you installed is version 1.2.0 which is too old. I would suggest you install it again.
Hallo, why does my trainLabels just error?
Good One..
trainLabels< to_categorical(trainy)
Error: object 'trainLabels' not found.. How to solve this
It should be:
Yes thanks so much
Hello Sir.EBImage Package is not getting installed for 3.4.3R Version.Kindly suggest.
If you not installed EBImage package yet, then you can make use of following link:
ua-cam.com/video/dKgEDAUUtoo/v-deo.html
use this code:
source("bioconductor.org/biocLite.R")
biocLite()
biocLite(c("GenomicFeatures", "AnnotationDbi"))
biocLite("EBImage")
library(EBImage)
Sir i am get an error
Error: object 'trainLabels' not found
Probably you missed running a previous line
How to proceed after following code and error?
#R code line:
trainLabels
It is really a pain to get tensorflow running on rstudio. First you have to install tensorflow on anaconda (there guides for it on youtube) and then on rstudio. (that worked for me)
Awesome video, Thank you. I still cannot install EBImage :(
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘EBImage’
To install EBimage package, you can run following 2 lines;
install.packages("BiocManager")
BiocManager::install("EBImage")
@@bkrai thank you so much. These two lines gave me the error above.
need help I cannot run the library keras and EbImage.... Is there any other requirements for this?
For installing keras, refer to this link:
ua-cam.com/video/hd81EH1g1bE/v-deo.html
when i run the code, the following error occur.
> model %>%
+ layer_dense(units = 256, activation = 'relu', input_shape = c(2352)) %>%
+
+ layer_dense(units = 128, activation = 'relu') %>%
+
+ layer_dense(units = 2, activation = 'softmax')
Error in eval(lhs, parent, parent) : object 'model' not found
> summary(model)
Error in summary(model) : object 'model' not found
can you help me?
have you declared the model object i.e model
Thank you very much it is a good tutorial
Thanks for comments!
can i resize the images without naming them manually? i need to resize 400 images)
This link provides steps to read any number of images from a directory.
hi I am getting the following error. kindly suggest the solution> pred % predict_classes(trainx)
Error in py_call_impl(callable, dots$args, dots$keywords) :
TypeError: float() argument must be a string or a number, not 'NoneType'
This code refers to line 62. Check earlier lines to make sure there are no errors.
No error prior to this line. Shall I reinstall keras ?
i have just follow your tutrial amd retrain your data but i got error on fitting model...as follows
Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: in user code:
File "C:\Users\LENOVO\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\keras\engine\training.py", line 1021, in train_function *
return step_function(self, iterator)
please help me to complete my trial...thanks
Sir I want to know more about binary_ cross entropy??
Try this for a good explanation: goo.gl/8CeqaR
Can I use Keras for Facial Recognition?
Yes and CNN is the best method to use.
What type of machine learning classification is this please?
It uses neural networks.
I have used your dataset and your code but still it gives me 0.5 accuracy... any idea why?
You can try running it again.
Bharatendra Rai I did try for around 5 times....Each time the same result...After that I left it alone..
Probably some minor issue in the code.
Dear Mr Bharatendra, thank you for the awesome video! I am getting the same results of Mr Kumar thought... I tried to review the code but was unable to find any mistakes. The model always predicts car!
Actual
Predicted 0 1
0 5 5
the histogram does not display an initial variation in the training and a posterior stabilization. The plot is stable in the same probability since the beginning!? Can you offer some insights in what is happening? I had some problems installing EBImage in the 3.5 R.
Send me your code to look at.
how to use tensorflow has a backend i m getting please help me out
Once you install Keras, tensorflow will automatically be used as backend.
hi Sir, thanks for very great video.I am getting error for the line number 34 & 35trainLabels
Hello, first of all thank you for making this tutorial! I am very new to R and machine learning, and this tutorial has really helped me to understand each of the steps. I am however coming up against an error regarding the input, and wondered if you had and suggestions?
when I use:
history %
fit(trainx,
trainLabels,
epochs = 30,
batch_size = 32,
validation_split = 0.2)
I get this error:
ValueError: Input 0 of layer sequential_10 is incompatible with the layer: expected axis -1 of input shape to have value 2352 but received input with shape [None, 20, 1]
*'sequential_10' is the name of the model in Kaggle I believe
For some reason I wasn't able to get tensorflow to work in R on my laptop (despite trying lots of different methods for 2 weeks), and so I am using a combination of R and a Kaggle Notebook using R script. I am doing the first steps (importing images, reshaping, binding) in R, then exporting 'trainx' and 'testx' as csv files, then loading those into Kaggle... is this where I am going wrong? I am using planes vs cars images, and I don't see any errors in the previous lines of code. Searching this error online hasn't proved to solve the situation yet either
The main issue is "expected input shape to have value 2352 but received input with shape [None, 20, 1]"
You need to fix this.
@@bkrai Hi, I have solved this, thank you!
Thanks for the update!
@@bkrai Hello again! Would you please be able to tell me if this is a feedforward or feedback/recurrent NN?