Can you please explain the maths how the values of thita in apple and banana is calculated for normal calculation. Any links to read the mathematics would be helpful as its hard to remember the formula.
On Colab, we have TF 2.0 installed, unlike on our lab where we have both TF 2.0 and 1.0. TF 2.0 supports eager execution which means you don't have to explicitly create a session and run the code in it. Here is a solution that you may want to check:
We are to find optimal values of theta. So we are using gradient descent to find the optimal weights. At every step, we change the there such that its value reached optimal value.
Theta is the parameters of the line we want to come up with such that we will be able to estimate the housing price. The theta represents the contribution of the individual parameters in determining the final price of house.
A primitive data type is a data type for which the programming language provides built-in support. Examples such as ndarray in Numpy, tensor in Tensorflow.
Here, I believe you are referring to w2. w2 is the bias (which sometimes is called the intercept). If you draw a straight line, it's equation looks like the following:
y = mx + c
Here, c is the bias/intercept, m is the slope. The bias is required because without it the line will always pass through the center point, and thus will give a line which would underfit the points.
You can refer to the End-to-End ML video where this has been explained in more details.
In Tensorflow session-1, the regression is done using tensorflow. Why here the target value is not dropped from the data set?. X is directly defined with the data set concatenated with one. At 2.02.09 time you can see the programe of linear regression using tensorflow.
The target value has been separated into the 'y' variable. This is the training dataset. You will not be able to train the model if you drop the value.
I am trying the first code of tensorflow using new notebook on my cloudxlab account. It showing tensorflow version 2 .when i am envoking the function Session() it showing "
module 'tensorflow' has no attribute 'Session'" this error. What to do?
The bias node in a neural network is a node that is always 'on'. That is, its value is set to 1 without regard for the data in a given pattern. It is analogous to the intercept in a regression model, and serves the same function.
I find that content on Deep Learning part of ML spl. course is from 2018. And now tensorflow 2 .0 is out..will the conent be updated from recent 2020 live course ? Also is it worth doing TF 1 and is is still useful in application part ?
This course is based on TF1. To answer your query, yes it is useful to learn TF1 since Deep Learning codes coded with TF1, unless ported to TF2, still exists in TF1. Also, the concepts will remain the same irrespective of which library you are using. So, be it TF1 or TF2 or if they release any other version in future, the basic implementation will remain the same. Having said that, we will consider your feedback for future implementations.
In the above video at 1:55:36, column with '1' values in multiplied by w2 and No. of visits by w1. Why so. what is w1 and w2? and why one with w1 and one with w2?
Nope, it's not at all needed. You can very well get a solution without it.
But consider a linear equation problem:
If, X =
[x11, x12, ...., x1n]
[x21, x22, ...., x2n]
..
&
the theta computed by our algorithm comes out to be,
? = [?1, ?2, ..., ?n]
then with, X.? = y_pred
y1_pred = x11*?1 + x12*?2 + ... + x1n*?n
This is simliar to y = m*x. But it's missing an intercept (y = m*x + c). This "c" here is called a bias and is highly useful in understanding/tuning an ML model.
So, if we were to just suffix a "1" coloumn to the X matrix above.
Now you get the eq. of form y =m*x + c.
As you see, ?0 is completely independent to any input (x). It determines how much our model is baised towards the input and Varying it will adjust all predictions equally.
Just kidding. You can add any number (k) you want; your equation would then become: y = mx + kc. Given both k and c are constant, you may as well write it as another constant - capital C. So now it becomes, y = mx + C. Ultimately your algo is gonna calculate this constant "C".
So, when using "1" as bias column, the eq would be, y1_pred = ?0 + x11*?1 + x12*?2 + ... + x1n*?n
For eg. If you algo predicted ?0 = 20, the eq would be, y1_pred = 20 + x11*?1 + x12*?2 + ... + x1n*?n
So, when using any random rumber say "4" as bias column, the eq would be, y1_pred = 4*?0 + x11*?1 + x12*?2 + ... + x1n*?n
When you apply the same code, it would now give ?0 considering it is already multipled by 4 beforehand as "5".
So applying this ?0 = 5 in the above,
=> y1_pred = 4*5 + x11*?1 + x12*?2 + ... + x1n*?n
=> y1_pred = 20 + x11*?1 + x12*?2 + ... + x1n*?n
Hence, ultimately it gives the same solution no matter what number you use.
Actually in some situations you may prefer to use numbers other than "1" so as the Gradient Descent has to make less number of hops to reach the solution, get out of local minima, controlled MSE fluctuations or to regularize better - This may requires knowledge of data. If you don't have that, just use 1.
All my disk space seems to be taken up by conda and pip folders. Things might break if delete them. (I did install or upgrade a few libraries based on the errors I got; but I really don’t recall what all?)
If there is a way to factory reset things, could you please do the same? It’s okay if I lose the files.
If you are talking about x0 from the slides, then please note that we add bias as the weight. Please go through the basics of Deep Learning tutorial to gain more clarity on that.
Hi When we define something as tf.constant, then it means it will be constant all thro' the computation. But if we define something as tf.Variable(3,name=x), It also plays same role as x=3.Then why we use tf.constant in housing dataset when calculating theta.Plz clarify. Thanks
Wall clock time is the actual amount of time taken to perform a job. This is equivalent to timing your job with a stopwatch and the measured time to complete your task can be affected by anything else that the system happens to be doing at the time.
CPU time measures the total amount of time the CPU spent running your code or anything requested by your code. This includes kernel time.
There is also another time, the User time. User time measures the amount of time the CPU spent running *your* code. This does not count anything else that might be running, and also does not count CPU time spent in the kernel (such as for file I/O).
Hi Using tensorflow, time taken is supposed to be less. But in notebook, in starting when we calculate function f traditionally and then using tensorflow.I compared time of both, It has been observed that in traditional approach it is taking 6.91 & in tensorflow case it is taking 8.82.Plz explain. Thanks Prachi
Hi There is also one more thing I have noticed that time taken will be less as we moved to better way of implementing sessions of tensorflow. Is this fact? The screenshots are below:
As you can see yourself, there are various ways to do a task in Tensorflow. So once you find the better way, it takes either same or less amount of time.
TypeError: Fetch argument <_io.TextIOWrapper name='simple.txt' mode='r' encoding='UTF-8'> has invalid type <class '_io.textiowrapper'="">, must be a string or Tensor. (Can not convert a TextIOWrapper into a Tensor or Operation.)
TypeError: Fetch argument <_io.TextIOWrapper name='simple.txt' mode='r' encoding='UTF-8'> has invalid type <class '_io.textiowrapper'="">, must be a string or Tensor. (Can not convert a TextIOWrapper into a Tensor or Operation.) Any resolution for above error?
Please login to comment
82 Comments
Hi Team,
Can you please explain the maths how the values of thita in apple and banana is calculated for normal calculation. Any links to read the mathematics would be helpful as its hard to remember the formula.
Thanks,
Birendra Singh
Hi,
Please study Machine Learning Pre-requisites(https://cloudxlab.com/assessment/playlist-intro/195/machine-learning-prerequisites) and feel free to go through the vide explanation again, as the maths is explained in the video.
Thanks.
1 Upvote ShareWhat is the error in above screenshot?...I was trying out the example code shown in video lecture in Google colab.
It is not allowing to run the code.
Thanks
Hi,
On Colab, we have TF 2.0 installed, unlike on our lab where we have both TF 2.0 and 1.0. TF 2.0 supports eager execution which means you don't have to explicitly create a session and run the code in it. Here is a solution that you may want to check:
https://stackoverflow.com/questions/57206247/how-to-fix-runtimeerror-the-session-graph-is-empty-add-operations-to-the-grap
Thanks.
Upvote ShareWhy we are calculating next step of theta??
Upvote ShareHi,
We are to find optimal values of theta. So we are using gradient descent to find the optimal weights. At every step, we change the there such that its value reached optimal value.
Thanks.
Upvote ShareWe are calculating theta
what is theta Is it housing price or something else??
Hi,
Theta is the parameters of the line we want to come up with such that we will be able to estimate the housing price. The theta represents the contribution of the individual parameters in determining the final price of house.
Thanks.
Upvote ShareWhat is primitive value??
Upvote ShareHi,
A primitive data type is a data type for which the programming language provides built-in support. Examples such as ndarray in Numpy, tensor in Tensorflow.
Thanks.
1 Upvote ShareAt 1:55:30
I did not understand.
Why we are adding 1 in every column??
Please give answer in 4-5 sentences.
If someone give us dataset will have to add 1 every time??
Upvote ShareHi,
Here, I believe you are referring to w2. w2 is the bias (which sometimes is called the intercept). If you draw a straight line, it's equation looks like the following:
y = mx + c
Here, c is the bias/intercept, m is the slope. The bias is required because without it the line will always pass through the center point, and thus will give a line which would underfit the points.
You can refer to the End-to-End ML video where this has been explained in more details.
Thanks.
Upvote ShareThis comment has been removed.
Hi,
Please follow the below link to change the kernel to tensorflow 2:
[EXPLAINED] How to run Tensorflow 2 notebooks in CloudxLab - Lab Support - CloudxLab Discussions
Thanks.
Upvote ShareHello,
Please let me know what do we mean by this line of code (if epoch % 100 == 0):
>> for epoch in range(n_epochs):
if epoch % 100 == 0:
print("Epoch", epoch, "MSE =", mse.eval())
Thanks
_______________________________________________
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
for epoch in range(n_epochs):
if epoch % 100 == 0:
print("Epoch", epoch, "MSE =", mse.eval())
sess.run(training_op)
best_theta = theta.eval()
print("Best theta: ")
Upvote Shareprint(best_theta)
Hi,
That means, we want to print the epoch number and mse.eval() for every 100th epoch. Hope this helps.
Thanks.
Upvote ShareHello Sir,
In Tensorflow session-1, the regression is done using tensorflow. Why here the target value is not dropped from the data set?. X is directly defined with the data set concatenated with one. At 2.02.09 time you can see the programe of linear regression using tensorflow.
Upvote ShareHi,
The target value has been separated into the 'y' variable. This is the training dataset. You will not be able to train the model if you drop the value.
Thanks.
Upvote ShareThis comment has been removed.
Hello Sir,
I am trying the first code of tensorflow using new notebook on my cloudxlab account. It showing tensorflow version 2 .when i am envoking the function Session() it showing "
Upvote ShareHi,
Please use the Python3 kernel for TF1.0. Refer to the below discussion:
https://discuss.cloudxlab.com/t/explained-how-to-run-tensorflow-2-notebooks-in-cloudxlab/5432
Thanks.
Upvote ShareWhy bias term is always 1,why not any other random no?
Upvote ShareHi,
The bias node in a neural network is a node that is always 'on'. That is, its value is set to 1 without regard for the data in a given pattern. It is analogous to the intercept in a regression model, and serves the same function.
Thanks.
Upvote ShareHow do i find out if tensorflow with GPU support is installed in my computer??? [i have GTX1050Ti gpu]
1 Upvote ShareHi,
Excellent question! Go over to the below link:
https://www.tensorflow.org/install/gpu
Here you will find a list of CUDA-enabled GPU cards.
Thanks.
Upvote ShareThank you..
Upvote Shareare the notebooks available in tensorflow 2.0 version because lot of functions which are used here are not present in 2.0
Upvote ShareHi,
The Machine Learning Specialization course is based on TF1.0, so we do not have the notebooks in TF2.0 yet.
Thanks.
Upvote ShareHi,
Could you please provide a screenshot of the error.
Thanks.
Upvote ShareCould you please brief me about what does tf.random_uniform does in tensor flow?
Upvote ShareHi,
It generate a random tensor in TensorFlow so that you can use it and maintain it for further use even if you call session run multiple times.
Thanks.
Upvote ShareThank you sir.
Upvote ShareHello Sir,
I find that content on Deep Learning part of ML spl. course is from 2018. And now tensorflow 2 .0 is out..will the conent be updated from recent 2020 live course ? Also is it worth doing TF 1 and is is still useful in application part ?
Thans,
HS
Hi,
This course is based on TF1. To answer your query, yes it is useful to learn TF1 since Deep Learning codes coded with TF1, unless ported to TF2, still exists in TF1. Also, the concepts will remain the same irrespective of which library you are using. So, be it TF1 or TF2 or if they release any other version in future, the basic implementation will remain the same. Having said that, we will consider your feedback for future implementations.
Thanks.
Upvote ShareIn the above video at 2:00:08, it is mentioned,
y= tf.constant(housing.target.reshape(-1,1),dtype=tf.float32,name='y')
I got what reshape is. That is clear. But, what is '.target'
Can't it be housing .reshape(-1,1) instead of writing housing.target.reshape(-1,1). Why '.target'
Hi,
Here we are referring to the target variable, the one which we are predicting.
Thanks.
Upvote Shareok. Thanks for your answer
Upvote ShareIn the above video at 1:55:36, column with '1' values in multiplied by w2 and No. of visits by w1. Why so. what is w1 and w2? and why one with w1 and one with w2?
Hi,
These are the weights representing the intercept and the coefficient.
Thanks.
Upvote ShareThanks for your answer. it is clear now.
Upvote ShareIn the above video at 1:46:46 Why we are adding extra 1 ???
Upvote ShareNope, it's not at all needed. You can very well get a solution without it.
But consider a linear equation problem:
If, X =
[x11, x12, ...., x1n]
[x21, x22, ...., x2n]
..
&
the theta computed by our algorithm comes out to be,
? = [?1, ?2, ..., ?n]
then with,
X.? = y_pred
y1_pred = x11*?1 + x12*?2 + ... + x1n*?n
This is simliar to y = m*x. But it's missing an intercept (y = m*x + c). This "c" here is called a bias and is highly useful in understanding/tuning an ML model.
So, if we were to just suffix a "1" coloumn to the X matrix above.
X =
[1, x11, x12, ...., x1n]
[1, x21, x22, ...., x2n]
...
Our model would automatically adjust to give us another ? to match the length. Let's call this ?0.
? = [?0, ?1, ?2 ..., ?n]
So now when you do a dot product above 2 matrix you get,
y1_pred = ?0 + x11*?1 + x12*?2 + ... + x1n*?n
y2_pred = ?0 + x21*?1 + x22*?2 + ... + x2n*?n
Now you get the eq. of form y =m*x + c.
As you see, ?0 is completely independent to any input (x). It determines how much our model is baised towards the input and Varying it will adjust all predictions equally.
That's the reason we add 1 here.
Upvote Shareokay thanks
Can you please give me some suggestion for btech final year projects on ML/DL? its very urgent
Upvote Sharewhy we are not adding any other number as bias why only 1?? please explain
Because 1 is a very neutral number and I like it!
Just kidding. You can add any number (k) you want; your equation would then become: y = mx + kc. Given both k and c are constant, you may as well write it as another constant - capital C. So now it becomes, y = mx + C. Ultimately your algo is gonna calculate this constant "C".
So, when using "1" as bias column, the eq would be,
y1_pred = ?0 + x11*?1 + x12*?2 + ... + x1n*?n
For eg. If you algo predicted ?0 = 20, the eq would be,
y1_pred = 20 + x11*?1 + x12*?2 + ... + x1n*?n
So, when using any random rumber say "4" as bias column, the eq would be,
y1_pred = 4*?0 + x11*?1 + x12*?2 + ... + x1n*?n
When you apply the same code, it would now give ?0 considering it is already multipled by 4 beforehand as "5".
So applying this ?0 = 5 in the above,
=> y1_pred = 4*5 + x11*?1 + x12*?2 + ... + x1n*?n
=> y1_pred = 20 + x11*?1 + x12*?2 + ... + x1n*?n
Hence, ultimately it gives the same solution no matter what number you use.
Actually in some situations you may prefer to use numbers other than "1" so as the Gradient Descent has to make less number of hops to reach the solution, get out of local minima, controlled MSE fluctuations or to regularize better - This may requires knowledge of data. If you don't have that, just use 1.
Upvote Sharethanks
Upvote ShareHey,
This may not be the right place; But I am unable to start the server (tried a few times).
Could you please help me out?
Thanks
Error:
500 : Internal Server Error
Spawner failed to start [status=0]. The logs for ssp5zone9739 may contain details.
Upvote ShareHi,
Are you talking about the Tensorboard server or your Jupyter notebook?
Thanks.
Upvote ShareThe entire Jupyter notebook. (Could not access any notebooks, terminal or workspace). I have tried starting the Server many times.
Hi,
You had exceeded your user disk space quota of 4GB. That's why Jupyter is not able to start. Please follow the steps given here to clean up the files.
Upvote ShareHi,
My local files are only around 500 MB.
All my disk space seems to be taken up by conda and pip folders. Things might break if delete them. (I did install or upgrade a few libraries based on the errors I got; but I really don’t recall what all?)
If there is a way to factory reset things, could you please do the same? It’s okay if I lose the files.
Upvote ShareThis is now resolved. Thanks Sandeep!! :)
Upvote ShareHi
Upvote ShareIn this, Why we need to add extra column(bias) data?do we need to do it always in tensorflow computations?
Thanks
Hi,
If you are talking about x0 from the slides, then please note that we add bias as the weight. Please go through the basics of Deep Learning tutorial to gain more clarity on that.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHi
Upvote ShareWhen we define something as tf.constant, then it means it will be constant all thro' the computation. But if we define something as tf.Variable(3,name=x), It also plays same role as x=3.Then why we use tf.constant in housing dataset when calculating theta.Plz clarify.
Thanks
Hi,
You can find more about the differences between tf.constant and tf.variable in the below link:
https://stackoverflow.com/q...
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareOk Thanks for clarification
Upvote ShareHi
Upvote ShareCan you please clarify the concept of diffrent timings as below:
CPU times: user 5 µs, sys: 0 ns, total: 5 µs
Wall time: 11.7 µs
Thanks
Hi,
Wall clock time is the actual amount of time taken to perform a job. This is equivalent to timing your job with a stopwatch and the measured time to complete your task can be affected by anything else that the system happens to be doing at the time.
CPU time measures the total amount of time the CPU spent running your code or anything requested by your code. This includes kernel time.
There is also another time, the User time. User time measures the amount of time the CPU spent running *your* code. This does not count anything else that might be running, and also does not count CPU time spent in the kernel (such as for file I/O).
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareThank u so much
Upvote ShareThnks
Upvote ShareHi
Upvote ShareWhat is the use of function "reset graph"?
Hi,
It clears the default graph stack and resets the global default graph.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareDo we need to always reset graph before implementiong a ny session?
Upvote ShareThanks
Hi,
It's best to reset your graph.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHi
Upvote ShareUsing tensorflow, time taken is supposed to be less. But in notebook, in starting when we calculate function f traditionally and then using tensorflow.I compared time of both, It has been observed that in traditional approach it is taking 6.91 & in tensorflow case it is taking 8.82.Plz explain.
Thanks
Prachi
Hi,
Could you please share a screenshot of the code you are running, and the time that each code takes.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHi
There is also one more thing I have noticed that time taken will be less as we moved to better way of implementing sessions of tensorflow. Is this fact? The screenshots are below:
One more screen shot
Hi,
As you can see yourself, there are various ways to do a task in Tensorflow. So once you find the better way, it takes either same or less amount of time.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHI
Upvote ShareI want to know that why we need to update repository using git pull which we do.
Thanks
Prachi
if there will be any update in the files present in repository by the cloudxlab team it will be updated using git pull.
Upvote ShareOk Thanks
Upvote ShareThis is to ensure you are working on the latest code. SOmetimes we update the code from our side.
-- Praveen Pavithran
Upvote ShareHi Sandeep, I am referring tensorflow.ipynb from deep learning section.
when i run below part of code:
sess = tf.Session()
sess.run(x.initializer)
sess.run(y.initializer)
result = sess.run(f)
print(result)
sess.close()
It is showing type error as below:
TypeError: Fetch argument <_io.TextIOWrapper name='simple.txt' mode='r' encoding='UTF-8'> has invalid type <class '_io.textiowrapper'="">, must be a string or Tensor. (Can not convert a TextIOWrapper into a Tensor or Operation.)
Can you please check and help on this.
Upvote ShareHi @@ganeshkumarpatil:disqus,
Curious if you found the solution of it on Google?
Upvote ShareHi Abhinav, Thanks for reply.
I could not find proper solution for this issue. I cannot install previous version of tensorflow on lab. Could you please help.
Upvote ShareTypeError: Fetch argument <_io.TextIOWrapper name='simple.txt' mode='r' encoding='UTF-8'> has invalid type <class '_io.textiowrapper'="">, must be a string or Tensor. (Can not convert a TextIOWrapper into a Tensor or Operation.)
Upvote ShareAny resolution for above error?
Hi Deepak,
Please follow this discussion for a solution:
https://discuss.cloudxlab.c...
Let us know if it worked for you.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Share