deeplearning.ai | Adrew Ng 's coursera course | Machine Learning library
kandi X-RAY | deeplearning.ai Summary
kandi X-RAY | deeplearning.ai Summary
The ~~notes and answers~~ of Adrew Ng's coursera course: deeplearning.ai. Course 5 will be released in December. The information in this repo is quit limit, but you can still email me for any questions. If you want to learn basic concept and pratice programme skills about machine learning, you can also try my github folder. It includes the python implementations of the basic machine learning programs. It helps a lot if you implement all basic algorithms by yourself.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of deeplearning.ai
deeplearning.ai Key Features
deeplearning.ai Examples and Code Snippets
Community Discussions
Trending Discussions on deeplearning.ai
QUESTION
I am trying to tune a basic neural network as practice. (Based on an example from a coursera course: Neural Networks and Deep Learning - DeepLearning.AI) I face the issue of the random weight initialization. Lets say I try to tune the number of layers in the network. I have two options:
- 1.: set the random seed to a fixed value
- 2.: run my experiments more times without setting the seed
Both version has pros and cons.
My biggest concern is that if I use a random seed (e.g.: tf.random.set_seed(1)
) then the determined values can be "over-fitted" to the seed and may not work well without the seed or if the value is changed (e.g.: tf.random.set_seed(1)
-> tf.random.set_seed(2)
. On the other hand, if I run my experiments more times without random seed then I can inspect less option (due to limited computing capacity) and still only inspect a subset of possible random weight initialization.
In both cases I feel that luck is a strong factor in the process.
Is there a best practice how to handle this topic?
Has TensorFlow built in tools for this purpose? I appreciate any source of descriptions or tutorials. Thanks in advance!
...ANSWER
Answered 2021-Jan-13 at 17:33Tuning hyperparameters in deep learning (generally in machine learning) is a common issue. Setting the random seed to a fixed number ensures reproducibility and fair comparison. Repeating the same experiment will lead to the same outcomes. As you probably know, best practice to avoid over-fitting is to do a train-test split of your data and then use k-fold cross-validation to select optimal hyperparameters. If you test multiple values for a hyperparameter, you want to make sure other circumstances that might influence the performance of your model (e.g. train-test-split or weight initialization) are the same for each hyperparameter in order to have a fair comparison of the performance. Therefore I would always recommend to fix the seed.
Now, the problem with this is, as you already pointed out, the performance for each model will still depend on the random seed, like the particular data split or weight initialization in your case. To avoid this, one can do repeated k-fold-cross validation. That means you repeat the k-fold cross-validation multiple times, each time with a different seed, select best parameters of that run, test on test data and average the final results to get a good estimate of performance + variance and therefore eliminate the influence the seed has in the validation process. Alternatively you can perform k-fold cross validation a single time and train each split n-times with a different random seed (eliminating the effect of weight initialization, but still having the effect of the train-test-split).
Finally TensorFlow has no build-in tool for this purpose. You as practitioner have to take care of this.
QUESTION
My code is very basic, just following the first lab from DeepLearning.ai's GAN specialization. However, my code does not have the same output, what is the reason for this. Sorry if this is just a silly mistake, this is my first experience with GANs. I begin by creating the Generator and Discriminator classes, my random noise function, and creating my models. I then run the training loop, but after 3 epochs, all of the outputs from the GAN are black.
...ANSWER
Answered 2020-Dec-17 at 10:19Your discriminator loss is wrong. The labels for the real images should be 1
instead of 0
.
Updated code:
QUESTION
ANSWER
Answered 2020-Dec-10 at 18:46Based on the conversation in the comments, we decided to compute the percentage of zeros (or very small values in the matrix). Suppose that the matrix is arr
. Then,
QUESTION
I think there is a problem with my cudatoolkit version ie. 10.0.130. I don't understand this error message. I want to use Gradcam (heatmap generator) on the x-ray image. It is the same code from AI for Medicine by deeplearning.ai, I want to run it on my machine and I am trying to create a REST API for this model.
...ANSWER
Answered 2020-Oct-19 at 11:50The problem was python 3.7 in my virtual env. I downgraded to python 3.6.5 and everything seems alright.
QUESTION
I am trying to generate YOLOv2 model yolo.h5 so that I can load this pre-trained model. I am trying to port Andrew Ng coursera Yolo assignment ( which runs in tensorflow 1.x) to tensorflow 2.3.
I was able to cleanly port it thanks to tensorflow uprade (https://www.tensorflow.org/guide/upgrade), But little did I realize that I cannot download the yolo.h5 file ( either its get corrupted or the download times out) and therefore I thought I should build one and I followed instructions from https://github.com/JudasDie/deeplearning.ai/issues/2. It looked pretty straight forward as I cloned YAD2k repo and downloaded both the yolo.weights and yolo.cfg. I ran the following the command as per the instructions:
python yad2k.py yolo.cfg yolo.weights model_data/yolo.h5
But I got the following error:-
...ANSWER
Answered 2020-Sep-20 at 20:18The above problem goes away when you upgrade all of your code under yad2k repo ( particularly yad2k.py and python files under models folder to tensorflow 2.x. The beautiful upgrade utility provided by tensorflow does the magic for you by replacing the original call to the compatible tf.compat.v1.space_to_depth(input=x, block_size=...)
Therefore for those who are planning to do the hard job of downgrading their tensorflow and keras, I would recommend them to try the tensorflow upgrade. This saves a lot of time.
This takes care of my model h5 file creation. My bad - I didn't think about it when I asking the question.
QUESTION
The code below was taken from TensorFlow in Practice by deeplearning.ai course in Coursera (computer vision example - week 2).
...ANSWER
Answered 2020-Jul-28 at 02:11Given the model.fit(training_images, training_labels), Tensorflow API automatically passes the training_images to the first layer.
Training_images is a tensor of shape (m, 28, 28, 1). where, m - Total number of training images, 28x28 - image size, 1 - channel (Gray scale),
tf.keras.layers.Flatten(), reshapes the(28, 28, 1) 28x28 image into -> (784,).
View this for the Flatten() method source code. https://github.com/tensorflow/tensorflow/blob/v2.2.0/tensorflow/python/keras/layers/core.py#L598-L684
QUESTION
I am trying to complete some homework in a DeepLearning assignment [deeplearning.ai
by Dr. Andrew N.G.(Stanford University)].
When I try the assignment in Coursera platform everything works fine, however, when I try to do the same imports
on my local machine it gives me an error,
ModuleNotFoundError: No module named 'lr_utils'
I have tried resolving the issue by installing lr_utils
but to no avail.
There is no mention of this module online(surprised me a bit) and now I started to wonder if that's a proprietary to deeplearning.ai
?
Or can we can resolve this issue in any other way!
...ANSWER
Answered 2018-Apr-01 at 13:13"lr_utils" is not official library or something like that. Purpose of "lr_utils" is to fetch the dataset that is required for course.
option (didn't work for me): go to this page and there is a python code for downloading dataset and creating "lr_utils"
- I had a problem with fetching data from provided url (but at least you can try to run it, maybe it will work)
option (worked for me): in the comments (at the same page 1) there are links for manually downloading dataset and "lr_utils.py", so here they are:
- link for dataset download
- link for lr_utils.py script download
- Remember to extract dataset when you download it and you have to put dataset folder and "lr_utils.py" in the same folder as your python script that is using it (script with this line "import lr_utils").
QUESTION
this code converts a 2-dimensional matrix to a vector that contains all the values of the matrix, however, I don't understand what does this means :
image.reshape(image.shape[0] * image.shape[1] * image.shape[2],1)I've searched in other forums such as the deeplearning.ai forum about what this line of code mean ... but it's as if nobody had the same doubt as me...
"""
GRADED FUNCTION: image2vectordef image2vector(image):
...ANSWER
Answered 2019-Oct-24 at 18:41image
has the shape in the form of (H, W, C) which stands for H:height, W:width and C:channel. For example, an RGB image of size 256x256 has the shape of (256, 256, 3) and it contains 256*256*3 number of elements in total.
Same amount of elements can be stored in a vector with shape (256*256*3, 1). This is what numpy.reshape
does. Shape of the final array should have the same number of elements in it with the input array.
QUESTION
I am currently taking the Deep Learning specialization by Deeplearning.ai on Coursera and am on the first assignment that requires implementing Neural Network with Logistic Regression mindset. The problem is that the assignment is implementation of Neural Network as Logistic Regression function for UNSTRUCTURED DATA (IMAGES). I have successfully completed the assignment, getting all the expected outputs. However, I am now trying to use the coded Neural Network for STRUCTURE DATA but come across broadcast error. Part of the code is as below :
The dataset code
...ANSWER
Answered 2019-Oct-05 at 14:11The *
operator is elementwise multiplication, and your arrays have incompatible shapes. You want matrix multiplication, which you can do with np.matmul()
or with the @
operator:
QUESTION
I'm learning regularization in Neural networks from deeplearning.ai
course. Here in dropout regularization, the professor says that if dropout is applied, the calculated activation values will be smaller then when the dropout is not applied (while testing). So we need to scale the activations in order to keep the testing phase simpler.
I understood this fact, but I don't understand how scaling is done. Here is a code sample which is used to implement inverted dropout.
...ANSWER
Answered 2019-Jul-27 at 08:58I got the answer by myself after spending some time understanding the inverted dropout. Here is the intuition:
We are preserving the neurons in any layer with the probability keep_prob
. Let's say kepp_prob = 0.6
. This means to shut down 40% of the neurons in any layer. If the original output of the layer before shutting down 40% of neurons was x
, then after applying 40% dropout, it'll be reduced by 0.4 * x
. So now it will be x - 0.4x = 0.6x
.
To maintain the original output (expected value), we need to divide the output by keep_prob
(or 0.6
here).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install deeplearning.ai
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page