Hands On with TensorFlow

You are currently auditing this course.
4 / 31

TensorFlow - Session 02

Slides

If you are facing issues with Tensorboard, please follow the steps given in this discussion on CloudxLab forum.


No hints are availble for this assesment

Answer is not availble for this assesment

Please login to comment

141 Comments

Can someone help me with this issue?

  Upvote    Share

Hi,

A good idea is to run the existing notebook(from cloudxlab repo). If that notebook runs smoothly, then it would be easier to introspect and understand clearly about the issue.

Thanks.

  Upvote    Share

Hello,

Thank you for the reply. Turns out mse_summary in tf v2.5 should be mse_summary = tf.compat.v1.summary.scalar()

This is because although tf.summary.scalar() exists in tfv2.5, it works differently and hence the tf v1 should be used to follow the code in the lecture.

 1  Upvote    Share

This comment has been removed.

Hi Team,

IFrame not able to embedd html on my jupyter. It is giving me a blank page. Is there any issue with my browser which is stopping it.Please let me know the solution, I am not abe to visualize tensor graphs on jupyter.

 

Regards,

Birendra Singh

 

 

  Upvote    Share

Hi,

Please attach the screenshot.

Thanks.

  Upvote    Share

Hi, is the Modularity(last topic of this video) part is over ? or their is another video for that.

  Upvote    Share

Hi,

Yes, this is the last video on this topic.

Thanks.

  Upvote    Share

At 50:14

I did not understand.

tf,Variable(0.2, name="b")

tf.Variable=(0.3,name="c")

What are we calculating here??

  Upvote    Share

Hi,

We are not calculating anything, we are simply declaring a variable here.

Thanks.

  Upvote    Share

i did not understand.

Tensor Board

Why are we creating summary in MSE in step2 ??

  Upvote    Share

Hi,

TensorBoard provides the visualization and tooling needed for machine learning experimentation.

Thanks.

  Upvote    Share

This comment has been removed.

Hi,

For using python, you no longer need to activate py36 environment.

All, you need to do is set the path using this command: export PATH=/usr/local/anaconda/bin:$PATH

Thanks.

  Upvote    Share

Hi,

Please go through the below steps if you are facing issues with Tensorboard:

https://discuss.cloudxlab.com/t/solved-cannot-start-tensorboard-server/5146

Thanks.

  Upvote    Share
Hi Team,
I am facing below error while running tensorflow.ipynb
module 'tensorflow' has no attribute 'reset_default_graph'
  Upvote    Share

Hi,

Please check the kernel you are using. Follow the below discussion for more details:

https://discuss.cloudxlab.com/t/explained-how-to-run-tensorflow-2-notebooks-in-cloudxlab/5432

Thanks.

  Upvote    Share

Thanks. It worked for Tensorflow 1

 1  Upvote    Share

I could not under this piece of coce in the deeplearning notebook <b>tensorflow.ipynb</b>. Maybe I have missed some basic python syntax.

def differentiate(f, x):
dx = 0.00001
return (f(x+dx) - f(x))/dx


def sq(x):
    return x*x

def cube(x):
    return x*x*x

differentiate(sq, 5)

when the 'differentiate' function is called, first paraemeter is just 'sq', How does that work when 'sq' function itself takes a parameter 'x'? If no parameter is supplied at the time

of the fucntion call, is there any default value that is assumed for parameter 'x'?

Thanks in advance

  Upvote    Share

Hi,

Functions can be parameters too! When sq is passed as a parameter, inside the differentiate() function it acts as a function. Try running f(x + dx) only from inside the differentiate function and observe the value it returns.

Thanks.

 1  Upvote    Share

Thank you sir  but i could not able to  see  tensor board with following URL

http://g.cloudxlab.com.ec2.internal :6006

Help Me how to do that 

  Upvote    Share

Hi,

Please go through the below link for a few troubleshooting steps:

[SOLVED] Cannot start Tensorboard Server - Lab Support - CloudxLab Discussions

If this does not help, please check if the required files have been saved for Tensorboard to display. Also, share a screenshot of how you are trying to start the Tensorboard.

Thanks.

  Upvote    Share

e

  Upvote    Share

For using python, you no longer need to activate py36 environment.

All, you need to do is set the path using this command: export PATH=/usr/local/anaconda/bin:$PATH

 

  Upvote    Share

Help Me,  i am stuck in the first step  of starting   Tensor board  , 

 

  Upvote    Share

3rd sreenshot

___________________________

  Upvote    Share

2nd sreenshot

________________________

  Upvote    Share

Hello,

I need your help in understanding few issues reproducing the Tensorflow graph on browser using web console. Please refer to the 3 images below and answer the queries below:

1) Why am I able to see only 2 runs /graph? Although when I refer to your video TensorFlow- session 02 - 2:24:13 part, I see that there are multiple runs inside the TensorBoard

2) Even the folder 'ml/deep_learning/tf_logs' does not contain multiple logs. Am I missing something here?

3) What steps do we need to take to visualize multiple logs and graphs?

4) Or if I am able to see only one log after executing the code once in Jupyter notebook, there will be only one graph? Please advise if I am wrong or else please guide.

Thanks

  Upvote    Share

Hi,

The number of graphs showing on Tensorboard depends on the number of graphs saved in the folder, which in turn depends on the code you wrote. Please do not compare what is shown in the lecture videos with your work because they may not match owing to various reasons including we may have supplied data separately to show how Tensorboard works.

You can go through the below link for more information on Tensorboard:

[SOLVED] Cannot start Tensorboard Server - Lab Support - CloudxLab Discussions

Thanks.

  Upvote    Share

One more question -

What does to, msev mean here?

>>  if epoch % 100 == 0:
                to, msev = sess.run([training_op, mse], feed_dict={X: X_batch, y: y_batch})
                erros.append(msev)

 

Thanks

__________________________________________________________________

# This is execution phase
# Fetch the mini-batches one by one then provide the value of x and y via the feed_dict parameter

erros = []
with tf.Session() as sess:
    sess.run(init)
    for epoch in range(n_epochs):
        for batch_index in range(n_batches):
            X_batch, y_batch = fetch_batch(epoch, batch_index, batch_size)
            if epoch % 100 == 0:
                to, msev = sess.run([training_op, mse], feed_dict={X: X_batch, y: y_batch})
                erros.append(msev)
            else:
                sess.run(training_op, feed_dict={X: X_batch, y: y_batch})
    best_theta = theta.eval()
print(best_theta)

 

  Upvote    Share

Hi,

These are variables where the output from the right side of the code is being saved.

Thanks.

  Upvote    Share

Hello,

Please let me know why are we using the this code below?

>> init = tf.global_variables_initializer()

Which global variables are we initializing and for what o/p will this function be used? 

When I look at the help it says: " An Op that initializes global variables in the graph.". Which graph and variables are we talking about here?

Thanks

______________________________________________________________________

#Let's implement mini-batch using placeholder nodes

reset_graph()

learning_rate = 0.01

# Let's make X and y as placeholder nodes

X = tf.placeholder(tf.float32, shape=(None, n + 1), name="X")
y = tf.placeholder(tf.float32, shape=(None, 1), name="y")

theta = tf.Variable(tf.random_uniform([n + 1, 1], -1.0, 1.0, seed=42), name="theta")
y_pred = tf.matmul(X, theta, name="predictions")
error = y_pred - y
mse = tf.reduce_mean(tf.square(error), name="mse")
optimizer = tf.train.GradientDescentOptimizer(learning_rate=learning_rate)
training_op = optimizer.minimize(mse)

init = tf.global_variables_initializer()

  Upvote    Share

Hi,

Please find a detailed answer in the below discussion:

tensorflow - What is the purpose of tf.global_variables_initializer? - Stack Overflow

Thanks.

  Upvote    Share

This comment has been removed.

This comment has been removed.

Hi Sir,

       Kindly, provide the tensor python code book which is using the latest tensorflow 2.0. Since, I have install the tensorflow 2.0. It is giving the error in the notebook that

AttributeError: module 'tensorflow' has no attribute 'reset_default_graph'. Kindly, help.
 

 

  Upvote    Share

Hi,

This course is built on Tensorflow 1.0. You do not need to install the same on your own computer, you need to use our lab for the same where we have installed TF1.0 and TF2.0 for you to be able to use them.

Thanks.

  Upvote    Share

Hi

I am not able to get the graph ,Its not giving any error. I am  running the code locally and I have created a new environment where tensorflow 1.10 and python 3.6.9  is installed .

  Upvote    Share

Hi,

Check if you have activated the correct environment, using the correct URL, see if you are using the correct directory where the graphs are stored.

Thanks.

  Upvote    Share

Hi,

Graph is not being populated in the notebook "tenserflow.ipynb" in the section "9  Visualizing the graph - 9.1  inside Jupyter and 9.2  Using TensorBoard"

Regards,

Punit

  Upvote    Share

Hi,

 

I am getting issue with Tensorboard. I got error for "source activate py36". Could not find py36 env. with "conda info --envs". I was still able to start the TensorBoard but not able to open it in the browser.

f.cloudxlab.com:6006

  Upvote    Share

Hi,

Please go through the below discussion:

https://discuss.cloudxlab.com/t/solved-cannot-start-tensorboard-server/5146

This should answer both your queries.

Thanks.

  Upvote    Share

Hi Rajtilak,

Thanks.

I executed the steps as suggested in the link. Please check below the outcome.

Started the TensorBoard server using following code but it gave an error "No dashboards are active for the current data set."

(Check the image below)

export PATH=/usr/local/anaconda/bin:$PATH
source activate root
tensorboard --logdir deep_learning/tflogs --port 4066

http://f.cloudxlab.com:4066

Am I missing something?

9  Visualizing the graph - 9.1  inside Jupyter
Error - Did not display the graph

9.2  Using TensorBoard
Executed the steps provided in first 3 cells i.e. till filewriter
file_writer = tf.summary.FileWriter(logdir, tf.get_default_graph())

Copied the name of the latest log file generated by the filewriter and eexcecuted the code (Check the image below)
!ls -lrt tf_logs/run-20200910082500
Output:
total 16
-rw-r--r-- 1 punitnb7985 punitnb7985 15836 Sep 10 08:25 events.out.tfevents.1599726315.cxln5

Executed next five steps till
show_graph(tf.get_default_graph())
Error - Did not display the graph

 

  Upvote    Share

Hi,

You need to provide the complete path to the folder containing the information, this is because the Jupyter notebook and the folder containing the information to display the graph are in different locations.

Thanks.

  Upvote    Share

Hi Rajtilak,

This is directory for log files as per the code.

root_logdir = "tf_logs"
logdir = "{}/run-{}/".format(root_logdir, now)

It is created in "/ml/deep_learning"

The tensorflow.ipynb is also located in "/ml/deep_learning" directory.

Please let me know which path and where to be changed.

  Upvote    Share

Hi,

Use the complete path to the folder containing the files.

Thanks.

 

  Upvote    Share

Hi,

Why we are calacualting Gradient ? Only to know the value of Theta or going to use it to Minimize the cost function i.e. MSE.

  Upvote    Share

Hi,

Here we are calculating the gradient to show how it can be done manually, without using any library, so the one can understand how it works.

Thanks.

  Upvote    Share

python 3 issue...no file in directory...Python 3 is not activated...kindly help

  Upvote    Share

Hi,

Please try the following line instead:

source activate root

Thanks.

  Upvote    Share

Hi, Rajtilak

Error: No such file or directory.

Regards

Mrityunjay 

 

  Upvote    Share

Hi,

Try these set of commands:

export PATH=/usr/local/anaconda/bin/:$PATH
source activate root

Just curious, what are you trying to achieve here?

Thanks.

  Upvote    Share

Hi, Rajtilak

I want to use TensorBoard.

Regards

Mrityunjay

  Upvote    Share

HI, i found this link but it is not opening kindly help me out.

http://cxln4:6006/

Error: This site can’t be reached

regards

Mrityunjay

  Upvote    Share

Hi,

Please go through the previous link I shared.

Thanks.

  Upvote    Share

http://cxln5:4066/

Error: This site can’t be reached

regards

Mrityunjay

  Upvote    Share

This site can’t be reached

cxln5’s server IP address could not be found.

 

DNS_PROBE_FINISHED_NXDOMAIN

  Upvote    Share

Hi,

Please go through the discussion in the link I provided, that explains what you need to do in this case.

Thanks.

  Upvote    Share

Sir i use tensorflow 2 so there are certain things not applicable from here when i try myself. I've tried using tf.compat.v1 in some cases, but got stuck here in summary.filewriter. could you please tell me what can i do to fix this problem?

  Upvote    Share

Hi,

I see that you have enrolled for the Deep Learning course from E&ICT, IIT Roorkee. This course was created using Tensorflow 1.0. Here are a couple of suggestions:

1. Use our lab for all the assessments, we have both Tensorflow 1.0 and Tensorflow 2.0 available there
2. If you have installed Tensorflow 2.0 in your personal computer but would like to practice these assessment there, I would suggest you to create another environment and install Tensorflow 1.0 for this purpose
3. Here is a code migration guide from Google, you can try this: https://www.tensorflow.org/guide/migrate

Let me know if you need any further help.

Thanks.

  Upvote    Share

sir could you please help me here, what does this selected line do? what is "to"?

 

  Upvote    Share

Hi,

sess is the session we created, and we are running it using the run function. Before this line we are fetching the mini-batches, and then we are feeding value of X and y via feed_dict parameter.

Thanks.

  Upvote    Share

sess=tf.session()

 

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-6c7cd0cabe5e> in <module>
----> 1 sess=tf.session()

AttributeError: module 'tensorflow' has no attribute 'session'
  Upvote    Share

Hi,

Are you trying to run this on the tensorflow2 kernel?

Thanks.

  Upvote    Share

yes,where should i run it then i was running it in cloudxlab tensorflow2

  Upvote    Share

Hi,

This is a Tensorflow 1 code, it will not run in Tensorflow 2. Please change your kernel to Tensorflow 1 to run this code, follow this discussion if you want to know how to change your kernel to Tensorflow 1:

https://discuss.cloudxlab.com/t/explained-how-to-run-tensorflow-2-notebooks-in-cloudxlab/5432

Thanks.

  Upvote    Share

In manually calculating method, we take initial value of theta as: tf.Variable(tf.random_uniform([n+1,1],-1.0,1.0,seed=42).

Could you please expain what is n+1 here and -1.0,1.0?

Also, is theta too a global variable?

Thanks.

  Upvote    Share

Hi,

random_uniform 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. E.g:

rand_tensor_ex = tf.random_uniform([1, 2, 3], minval=0, maxval=1, dtype=tf.float32, seed=None, name=None)

Here, we're going to create a tensor that’s 1x2x3 with a minimum value of 0 and a max value of 1, and the data type that we're going to use is tf.float32. Also, we're not going to use a seed and we're not going to give it a name.

Thanks.

  Upvote    Share

Thank you.

Just one more question. Why are we taking (n+1) and not just n?

  Upvote    Share

Hi,

Good question! Instead of me answering this, let me help you answer this. Why don't you create 2 variables, one with n and another with n+1, and then print them to see the results. That would help you understand the difference.

Thanks.

  Upvote    Share

In the above video at 1.28.59, the following equation is being shown. It is about converting the data to real-time data. But I didn't got the concept of these equations. like, epocj is multiplied by n-batches and added to batch_index. why multiplied to n_batches. 

then again, nbatches is calculated as int(np.ceil(m/batch_size)). what is m. why we dividing by batch size.

Please explain.

  Upvote    Share

In the above video at 1.39.31, it is been explained about m. So, that is clear now. Now, i am only facing problem in understanding the fact about batch_index...batch_index is not defined. i understand what index is. But dont we need to define it. 

  Upvote    Share

Hi,

These are function parameters that we will pass later while calling the function.

Thanks.

  Upvote    Share

Hi,
Can you please provide me a tutorial or simplified code for these 2 projects

cross attenation for image text
2)text to image conversion

please reply sir it is an urgent need.

Thank you

 

  Upvote    Share

Hi,

I am running this locally in tensorflow2.2.0 and successfully runned all the above codes and successfully showing the results.
But just on running "show_graph(tf.compat.v1.get_default_graph())" it is not showing and graph but it is also not showing any error. Please help me out. 
Thanks

  Upvote    Share

Hi,

Probably this function is not compatible in Tensorflow 2, even if you are using compat. Try Stackoverflow if you do not find a solution.

Thanks.

  Upvote    Share

I have not found any solution even in stackoverflow please help me sir

 

  Upvote    Share

Hi,

I would not be able to help you much since you are running these codes on your local system, I don't know it's configuration, the packages installed, version number of different packages etc. Best thing for you would be to either port your code to TensorFlow 2, or post your question on Stackoverflow in case you did not find a solution there.

Thanks.

  Upvote    Share

Hi,

How can we run tensorboard locally and not in cloudxlab?? as i am unable to proceed fiurther now. 

 1  Upvote    Share

Hi,

Follow the same instructions. In place of the URL, type in localhost:<port#>, and you are good to go.

Thanks.

  Upvote    Share

i have not understood. for example- if port no. is 8080 then is it locahost:8080????

  Upvote    Share

Hi,

If you are trying to run Tensorboard on your local machine, the URL should be localhost: and then the port number.

Thanks.

  Upvote    Share

Hi,

I have tensorflow version- (in my local device)

import tensorflow
print(tensorflow.__version__)

2.0.0
but I am getting this error while executing reset default graph. please help me sir
(error:please see below and  the picture i have uploaded)
AttributeError: module 'tensorflow' has no attribute 'reset_default_graph'
AttributeError: module 'tensorflow' has no attribute 'Session'
AttributeError: module 'tensorflow' has no attribute 'global_variables_initializer'

 

 

  Upvote    Share

Hi,

I have already replied to your email. Please check.

Thanks.

  Upvote    Share

I have done the same as shown in this link

https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/ 

but still showing the same error. please help me sir 

  Upvote    Share

Hi,

You cannot use reset_default_graph in Tensorflow 2. You need to find another way to code the same.

Thanks.

  Upvote    Share

Hi,

for epoch in range(n_epochs):
        if epoch % 10 == 0:
            print("Epoch", epoch, "MSE =", mse.eval())
        x = sess.run(training_op)
    best_theta = theta.eval()
In this loop what is the significance of this line???

  Upvote    Share

Hi,

Could you please tell me which line are you referring to?

Thanks.

  Upvote    Share

I have understoof my doubt

 

  Upvote    Share

Hi,

theta = tf.Variable(tf.random_uniform([n + 1, 1], -1.0, 1.0, seed=42), name="theta") 

in the above code why we are writing [n + 1, 1 and  -1.0, 1.0????

  Upvote    Share

Hi,
I have come upto here(screenshot). then in another browser I do: f.cloudxlab.com/6011
--> error: Site cant be reached. Page took too long to respond.
Any suggestions? can't be the internet. I am able to watch video without buffer.

  Upvote    Share

Able to use port 4100 based on discussion in threads below. Issue resolved. Thanks.

  Upvote    Share

Hi,

This is great! Happy learning.

Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

Hi,

Please refer to the following discussion for a solution:
https://discuss.cloudxlab.c...
Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

After launching tensorboard on terminal, i m not able to open it in browser (screenshot attached

). Its giving error "This site cant b reached". I have tried many different ports but its not running. Please respond.

  Upvote    Share

Hi,

Are you still facing this issue? If yes, then please follow the below steps for resolving the issue:
https://discuss.cloudxlab.c...
Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

Hi,

I am unable to open tensorboard in the browser after launching it from the terminal. Screenshot attached

Please help.

  Upvote    Share

Hi,

Are you still facing this issue? If yes, then please follow the below steps for resolving the issue:
https://discuss.cloudxlab.c...
Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

Hi
I am not able to open tensorboard in browser as shown ion screenshot

. plz help.
Thanks

  Upvote    Share

Please check this note on Tensorboard

-- Praveen Pavithran

  Upvote    Share

Can we not use the packages like we used to do in sklearn for applying different kinds of models?

  Upvote    Share

Hi,

Could you please elaborate a bit more on your query? We are using Tensorflow here, which itself is an open source library for Deep Learning.
Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

i am asking that in sklearn we have different types of models, so is it same in case of tensorflow?

  Upvote    Share

Hi,

Yes, it does. You can explore them yourself from the below link:

https://www.tensorflow.org/...

Happy learning!

Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

Hi
I am not able to activate python3 in console for running tensorboard. Plz help
Thanks

  Upvote    Share

Hi.

Kindly export this path export PATH=/usr/local/anaconda/bin:$PATH in your web-console and you will be able to access the Python3.

All the best!

-- Satyajit Das

  Upvote    Share

Thanks But I have created a tensorboard at port 6006 but i ma unable to open in browser . Plz help

  Upvote    Share

Hi
In Visualizuing the graph portion, code is running without any error but graph is not displayed.Plz help.
Thanks
Prachi

  Upvote    Share

Hi,

Would request you to share a screenshot of your code.

Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

Hi
How we would decide momentum factor value in momentum gradient descent optimizer?
What is better approach out of gradient descent optimizer and momentum gradient descent optimizer ?

  Upvote    Share

Hi,

In practice, the coefficient of momentum is initialized at 0.5, and gradually annealed to 0.9 over multiple epochs. You can find more details here:
https://blog.paperspace.com...
Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

Thanks

  Upvote    Share

Hello,

when i am trying to get grap inside jupyter using the same code. it is just showing blank.. no graph..
please help me out with it...
i have pasted it at the end of code after eveluating...
do we have to draw just after graphing code?

  Upvote    Share

Please share screenshot of code if this issue persists

-- Praveen Pavithran

  Upvote    Share

housing_data_plus_bias = np.c_[np.ones((m, 1)), housing.data]

here what is np.c_ ??

  Upvote    Share

Hi
np.c_ is used to concatenate housing data and array which u have used os size (m,1).Hopw it would help.

  Upvote    Share

thanks Prachi

  Upvote    Share


why am i not getting the value of x when i print it even after i used the global variable initializer and ran it

  Upvote    Share

Hi,

KIndly check your syntax once.
sample example :-
with tf.Session() as sess:
x.initializer.run()
y.initializer.run()
result = f.eval()
result

All the best!

-- Satyajit Das

  Upvote    Share

Hi
I'm getting this error.

  Upvote    Share

Hi Roshan,

Please ensure that the folder exists. If it does not, would request you to clone our git repository as per the tutorial.

Thanks.

-- Rajtilak Bhattacharjee

  Upvote    Share

Another question : The function: gradients = Gradient(ops,[theta]) [0]

Will the elements in the gradients list be the same as the number of elements in the theta list?
I didn't see you define the theta list in the video , if you did , please tell me where it is,

  Upvote    Share

A question : what is the metaphor meaning for the tesorflow session?

  Upvote    Share

When tried to activate py36 below issue came

  Upvote    Share
Abhinav Singh

This is not the right way

  Upvote    Share
Abhinav Singh

Please follow the steps in the video

  Upvote    Share

Please help me with below issue.

  Upvote    Share
Abhinav Singh

You have to first activate the py36 environment . Please follow the steps in the video

  Upvote    Share
Abhinav Singh

Please follow the video. you will have to activate python 3 environment first

  Upvote    Share

Once we created a session, we need to close the session right..!!, but why do you not closing the session after it's use?

  Upvote    Share

for mini batch gradient descent, X is having 8 features, for place holder of X, why do we need to use n + 1?

  Upvote    Share

While working on the terminal i am not able able to import tensorflow as the module is absent. I am not able to install it as well due to some permission issues. I believe that is why i am not able to use tensorboard. Can you please help?

  Upvote    Share

Hi Anurag,

I am looking into it. In the meantime, please use the jupyter notebook.

  Upvote    Share

source activate py36 gives the error: "bash: activate: No such file or directory"

  Upvote    Share

The python3 is in anaconda directory. Please run the following command to run python3:

export PATH=/usr/local/anaconda/bin:$PATH

But I would strongly suggest that you use the jupyter notebook by using "New -> Python3" in the Jupyter Home.

  Upvote    Share

instead of source activate py36 .. try
source activate root
then you can check
python --version

  Upvote    Share