Analyzing Models with TensorBoard - Deep Learning with Python, TensorFlow and Keras p.4
Vložit
- čas přidán 27. 08. 2024
- Welcome to part 4 of the deep learning basics with Python, TensorFlow, and Keras tutorial series. In this part, what we're going to be talking about is TensorBoard. TensorBoard is a handy application that allows you to view aspects of your model, or models, in your browser.
Text tutorials and sample code: pythonprogramm...
Discord: / discord
Support the content: pythonprogramm...
Twitter: / sentdex
Facebook: / pythonprogramming.net
Twitch: / sentdex
G+: plus.google.co...
My day routine :
1) Open youtube
2) Check sentdex new tutorials !!
Thank you for this amazing work !!
Wow hitting CMD from file explorer path just saved me a huge amount of time, no more batch files. awesome shortcut. thanks for the tip!
if you get a "Failed to create a directory" error as a windows user i fixed it by changing "/" to "\\" in log_dir.its looks like this now = TensorBoard(log_dir=" C:\\logs\\{}".format(NAME))
thank you very much, your comment save my life
Thanks alot bro :)
thanks
That awesome share man, you saved the day
Also we can use without format
Name = f"tfModels-{int(time.time())}"
tensorboard = TensorBoard(log_dir=f"logs\\{Name}")
If you get "ValueError: Failed to find data adapter that can handle input" use
import numpy as np
X = np.asarray(pickle.load(open("X.pickle", "rb")))
y = np.asarray(pickle.load(open("y.pickle", "rb")))
You are a lifesaver bro. Thanks for the help!
You effin Lifesaver !! THANK YOU!
"I really hope that didnt kill my recording"... doesnt check :P This video series is great btw!
Can't check without hitting stop. Then I'd have to... *shudders* edit. Might as well just finish and hope for the best :D
up next teach charles to edit? that actually would be super cool
7:42 "one more time" -> "un mas tiempo" LOL!
Nice tutorial!
una vez mas
Great video as always, Harrison. Thank you very much for taking the time to make such high-quality content. Cheers.
seriously, that was the best explanation for how to use tensorboard, thx
The best tutorial ever! BTW, for 2020 mac user, if you cannot run the: tensorboard --logdir=logs/, use the pip install grpcio==1.24.3
if you get a AttributeError: module 'tensorflow' has no attribute 'Session'
/ or ConfigProto / or GPUOptions
then you must change it to : tf.compat.v1.GPUOptions /tf.compat.v1.Session/tf.compat.v1.ConfigProto
where I have to do this change
@@alokkr029 gpu_options = tf.compat.v1.GPUOptions(per_process_gpu_memory_fraction=0.333)
sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(gpu_options = gpu_options))
when Sentdex runs this code it shows 17000 + samples but when I Run this it shows only 500 samples so how can I increase my samples no. please help me if anyone gets me. plzzzzzzzzzzzzz
for window user remove "/" for tensorflow directory path to tensorboard = TensorBoard(log_dir="logs{}".format(NAME)) . At the beginning kindly include log_dir = os.path.join(
"logs",
"fit",
datetime.datetime.now().strftime("%Y%m%d-%H%M%S"),
)
if u are having this issue ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
9
10 # this for run many models on the same time, by fractioning the vram u use, like an object detection
---> 11 gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333)
12 sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
13
AttributeError: module 'tensorflow' has no attribute 'GPUOptions'
Try using this
gpu_options = tf.compat.v1.GPUOptions(per_process_gpu_memory_fraction=0.333)
sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(gpu_options=gpu_options))
Was eagerly waiting for this, thank you @sentdex !!
Happy to share!
'tensorboard' is not recognized as an internal or external command,
operable program or batch file.
i got this error could u help me ? Thank u:)
Same
i can only see epoch_accuracy and epoch_loss on my tensorboard and not those graphs that are shown in your video. can anybody point out a solution for this. thanks a bunch
Did you find a solution? If you do, please let me know
Really really useful ,thank you Harrison, you're awesome.
I get an error saying that a cirectory could not be created in relation to logs/Tagged-vs-untagged-cnn-64x2-1563446211\plugins\profile\2019-07-18_11-36-52 (with tagged-vs-untagged etc being my version of cats and dogs file name). Any ideas how to fix? This error is related to tensorflow.
tensorboard=TensorBoard(log_dir='logs\{}'.format(NAME))
put a forward slash instead of backslash in logs, that solved the problem for me
"One more time" -> "Un maś tiempo" wrong -> "Una vez más" right
Awesome tutorial series man :D
So imma be prob still sayin un mas tiempo still xD. It's official Sentish language, sir!
Thank You Sir, this tutorial helped me a lot!!! I really am a big fan of your videos.
Hey, insted of showing 4 graphs I am only able to see 2 (epoch_accuracy and epoch_loss) not like yours and also even after one run they showed up 2 (as train and validation)
how can i see separate 4 graphs
hey bro same , i guess it is due to update in 2020.
also i can not find the log file in my directory since i am using jupyter notebook (if you have the solution plzz tell)
i used
%load_ext tensorboard
import tensorflow as tf
import datetime, os
logs_base_dir = "./logs"
os.makedirs(logs_base_dir, exist_ok=True)
%tensorboard --logdir {logs_base_dir}
this to load tensorboard
@@amoghchavan6373 Sure, No it's not jupyter notebook's problem. You can do that with jupyter...
You don't need to use OS for making directory. log_dir(argument) in tensorboard, will create path you specify.
This is the code i'm using,
NAME = "{}-conv-{}-nodes-{}-dense-{}".format(conv_layer, layer_size, dense_layer, datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))
tensorboard_callback = TensorBoard(log_dir="logs\\{}".format(NAME))
In my case i'm simply generating 'logs' folder(which is created by tensorboard) in jupyter notebook's folder where my code file is...
Please check your log_dir argument. Your logs might be at that place.
Hope this solves your problem. Ask if you still stuck there...
@@_spartian_ thank you for your help , also i have completed the entire model without any errors . if u need any help then let me know
do you also use the 1080ti for gaming or is it a pure workhorse?
Thank you so much this part helped A LOT.
got errors in cmd while running (tensorboard --logdir = logs/) then, use this that worked for me
(tensorboard --logdir logs)
Me to
But your help doesn't work doesn't work
are you planning on doing something about genetic/evolutionary algorithms? In future, maybe evolutionary neural nets?
If you applied tutorial 3 on Google Colab as me, then the below code will work from you to have tensorboard running there.
from datetime import datetime
logdir = os.path.join("logs", datetime.now().strftime("%Y%m%d-%H%M%S"))
tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1)
model.fit(X, y,
batch_size=batch_shape,
validation_split=0.1,
callbacks=[tensorboard_callback])
Then in a new cell use the below to open the TensorBoard
%load_ext tensorboard
%tensorboard --logdir logs
That's incredible~
I'm waiting for ur next video.
Great work. Keep us educating @sentdex
Will do!
Hey Sentdex, love you tutorials. Thank you for taking the time to put them up.
Will you cover any PyTorch tutorials?
why do I only get epoch_accuracy and epoch_loss graphs? Any ideas? thanks.
hey my screen shows the same too...Any ideas how to make it appear similar to this tutorial?
I got the same too, can not find a solution
I have a question, I located my working directory and typed "tensorboard --logdir=logs/" as but i got this error "'tensorboard' is not recognized as an internal or external command, operable program or batch file." Can anyone help me?
I love these tutorials!!!!!!
I love keras!!!!!!!
Unlike many other stupid tutorials, everything is explained very well and the code actually works!
This was great, Thank you!!
Thank you @sentdex you are really awesome and this tutorial🔥🔥🔥🔥🔥
And in the terminal have the next error:
it shows "tensorboard' is not recognized as an internal or external command,
operable program or batch file" , does anyone know how to solve it?
python -m tensorboard.main --logdir=[path]
in cmd..... python -m tensorboard.main --logdir=logs/ --host localhost --port 8088
@@gianistatie207 python -m tensorboard.main --logdir=logs/ worked for me
I'm stuck at 9:34
I type everything into Command prompt. I copy the link. Type into Chrome. And go to TensorBoard.
..... *"No dashboards are active for the current data set."*
Either:
A) first time users of Tensorboard need to preform an extra step (which perhaps should have been included.)
B) Using Tensorboard in Windows is slightly different than using on a Mac. Which is possibly the case since sentdex said _"anyway, on Windows it can get kind of finicky on you. Its weird"_ ......
C) I screwed up somewhere. This is always a possibility.
I'm going to go look for other tutorials, since who knows if/when this will ever get a helpful reply :'(
(This tutorial had been great up until that point. And will certainly be back for the rest of the video series after I fix the problem. However long that might take)
Long story short:
tensorboard --logdir=foo:"C:\Path\To\Files"
Something about the use of semicolons within the window's file-path cases it to not work.
Therefore putting *_foo:"_* before the file-path fixes it.
@@shanerooney7288 You're a hero, man. Thanks a bunch.
@@shanerooney7288 Thank you. It was helpful
2:02 "Without the activation function becomes like a linear activation function". This is not correct. Linear activation function is still a legit activation function. W/ the activation function becomes a linear regression model.
Sweet fancy Moses...I can definitely tell that I don't have a dedicated GPU. Each epoch is averaging around 115s, which is leaps and bounds slower than yours. Makes trial and error quite a bit more tedious.
please what is the most recent way to do GPUOptions and Session? Apparently GPUOptions and Session are deprecated. I am getting errors that tensorflow does not have those as modules.
Hi @sentdex, how likely are your tutorial series still "compatible" with TensorFlow 2.2 ?
try this if GPU options not worked :
gpu_options = tf.compat.v1.GPUOptions(per_process_gpu_memory_fraction = 0.333)
sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(gpu_options=gpu_options))
Keep going. it's very useful for me. Thanks a lot
Anh ơi, em bật cái tensorboard lên thì không thấy val_loss với val_acc, anh biết cách sửa ko ạ
update - Jan 2024 ( GPU limiting )
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession
config = ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.333
session = InteractiveSession(config=config)
Anyone else 'tensorboard' is not recognized as an internal or external command,
operable program or batch file. in CMD?
Answer: stackoverflow.com/questions/47985835/tensorboard-is-not-recognized-as-an-internal-or-external-command
Use localhost: instead
I have a Question how did all the epochs ran simultaniously I get one epoch at a time
I would like to ask one question. I am using the exact route that you used. In each run, I am taking different values in accuracy and loss. That is why, the plots are different every time compared to the previous ones in TensorBoard. Is the training of data necessary again? or there is something different that we should also insert. Thank you.
Hello Dex, I am having the weirdest issue with this.
I will change nothing in my code except adding from tensorflow........ import tensorboard
The minute i add this my loss goes from .08 to 1.6 and nothing in the underlying code has changed? I am extremely confused
My validation accuracy and validation loss are not showing in TensorBoard. Anyone know the solution?
I have trained a custom model with 3 classes, using SSD MobileNet in TensorFlpw, Is there a way to find the average precision of these individual classes ?
I fixed "Module 'tensorboard.util' has no attribute 'Retrier'" by doing "pip uninstall tensorboard" and "pip uninstall tensorflow-tensorboard", then running "pip install tensorflow-tensorboard". NOTE: different versions of tensorflow need different versions of tensorboard, for tensorboard to work properly. The modules are independent of eachother, but if your tensorboard isn't working, try getting your version to match up closer with your tensorflow version (i'm using tensorflow 1.5, and tensorboard 1.5.1)
hi!
thanks for your video
I just dont get something about using tensorboard, why dont we use matplotlib and draw our plots with that like always?
what is the difference?
if you use from keras.callbacks import TensorBoard you don not have to initialize it ;)
took me some time to figure that out
I actually screamed out “YESSS!” at my work office when I got the notification for this... I’ve reached new lows (highs)
The reason why the server stopped on first attemp was that you put carret in CMD line. In windows it pauses the running process)
Can I Also try this on Pycharm IDE? Or do I Really need to Install SUblime?
I get this error :- NotFoundError: Failed to create a directory: logs/Cats-vs-dogs-CNN\plugins\profile\2019-08-08_11-24-38; No such file or directory
So do I.
In the log_dir, change the / to \\ if you're running windows
@@FredPower_ you saved my day thank you
@@abdulsemedyasin2975 but not mine am also facing that problem
@@abdulsemedyasin2975 File "", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Failed to create a directory: logs/dogs-vs-cats-cnn-64*2-1578562165; Invalid argument [Op:CreateSummaryFileWriter]
I realized that you called the numbers on the x-axis epoch while Tensorboard has it labeled as step. So do in this case step is equivalent to epoch?
tensorboard part is not working at all, get the "No dashboards are active for the current data set." result
try alot ways still cant solve it, anyone hv any idea how to solve this issue? is the syntax outdated?
i love how u say "un mas tiempo", im from mexico and you say here "Otra vez"
Guys if you get an error importing Tensorboard it is because now it is called TensorBoard! Probs you can get an error if you do not change the name...
POTENTIAL FIX FOR SOME:
SUMMARY:
I'm using an anaconda environment (added to PATH during installation of anaconda), running the gpu-version of tensorflow and launching jupyter notebook from inside this environment. I called this environment "tensorflow-gpuenv" (relevant for later step). Running tensorboard --logdir=logs, failed to execute for me.
FIX:
As instructed, open the the directory containing the logs folder in explorer and type cmd to open the prompt.
type "activate tensorflow-gpuenv" (where tensorflow-gpuenv is the name of the environment you launched jupyter from within)
type "tensorflow logdir=logs"
you should get an address to paste into your searchbar now. For me, i could only load this url after copying the url with ctr-c (which it tells you will exit). I have yet to check if the other local host fixes, in this comment section, remove the need for this but i can view my models fine as is. hope this helps some.
"As instructed, open the the directory containing the logs folder in explorer "
by logs folder, do you mean the folder with cats and dogs in it?
Try using pycharm CE to make the tutorials even better!
Hi sir, I hope that u are fine.
When running in the (Anaconda) command prompt, correct environment, I get an error:
AttributeError: module 'tensorboard' has no attribute SessionRunHook.
Can you help me with this?
Thank u for every thing ^_^.
Use tensorflow.compat.v1 worked for me
Hello when I'm using tensorboard i get this issue ProfilerNotRunningError: Cannot stop profiling. No profiler is running.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
i cant find the error, please help upon it.
Hi - great video. With the example given, my PC takes about 10 minutes per epoch, and wanted to know if you have any tips for speeding things up. I'm using a fairly dated Dell XPS8300, Intel Core i7-2600 CPU, 16 GB RAM, NVIDIA GeForce GT 545 display adapter. I'm using the CPU only version of Tensorflow. If I install the GPU version of tensorflow, will that help do you think? I'm trying to avoid buying a new PC!
Why you have used sigmoid activation in dense ???
Could you make a segmentation cnn instead of a classification one afterwards? Im really interested in that
Hey Sentdex,What's the theme of Sublime text editor that you are using? I really liked it..Anyway great tutorial series as always!!
do you know how to use tensorboard in google colab? i already tried this:
!pip install tensorboardcolab
from tensorboardcolab import TensorBoardColab, TensorBoardColabCallback
tbc=TensorBoardColab()
but, after adding the callback with
model.fit(X, y, batch_size=32, epochs=1, validation_split=0.3, callbacks=[TensorBoardColabCallback(tbc)])
i get this errormessage:
KeyError Traceback (most recent call last)
in ()
51 metrics=['accuracy'])
52
---> 53 model.fit(X, y, batch_size=32, epochs=1, validation_split=0.3, callbacks=[TensorBoardColabCallback(tbc)])
i dont know why
so do i.
Is there a function that allows me to see the improvement in percentage?
Supposedly, that percentage is reduced but I can see somehow.
awesome video man
not matching prediction for cats, did with many pictures but the result was [[4.1456 (something)]]. did your codes as well but the result was the same, for dogs though the results were good. please help!
Thank u for this awesome video
After I load tensorboard it tells me no dashboards are active for the current data set. Any ideas?
Probably wrong directory
Write complete dir path
I have 1 question, How can I get the accuracy score for each class? I want to know from class 1 what accuracy I got, from class 2 what accuracy I got?
%reload_ext tensorboard
%tensorboard --logdir '/content/drive/My Drive/Colab Notebooks/Deep_Learning/logs'
For those using Google Colab with mounted Drive
Hi ! long time fan. How is it possible that at the 11 minute mark you have validation loss and accuracy both increasing? Shouldn't they be 100% inversely correlated? Thanks!
How do you delete log files from there? It doesn't let me delete old runs
to get those graphs we can just simply use matplotlib library right???
No dashboards are active for the current data set. Please help
The line *tensorboard = TensorBoard(log_dir='logs/{}'.format(MODEL_NAME))* throws me error of invalid syntax. Why was it? TensorBoard 2.1
MODEL_NAME = "CNN_1-{}".format(int(time.time())
I was reading Conv2d reference from TensorFlow page and I can see that it has stride=, activation= and many other parameters that can be set to it. So, I wonder if we can eliminate the Activation() layer and use the activation= param of Conv2D instead ? Thanks for the video, it is great.
what should i do if the val_acc is too low than the accuracy ?
When Im soppouse to write in my "cmd tensorboard --logdir=logs/" nothing but this shows up
ValueError: Not a TBLoader or TBPlugin subclass:
Can anyone help me?
Use dark mode for all videos wherever possible
AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'SessionRunHook' how to resolve this
Instead of Remove Dense layer why not try with dropout?
Can I make a prediction with an R-CNN with that .model I trained by watching your previous videos? How do I do that? I want to see if I have two flowers in the same image. Thank you
"ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following types in the input "
help
that happened to me too, just add this before you define the model
y = np.array(y)
hi I'm a newbie to machine learning. I'm using jupyter noteebook but when i run my code i cant seem to find the logs folder and when i try to run the command: tensorboard --logdir=/logs
the url generated (on running) says 'laptop-jim919ih refused to connect.'
Please help! Thanks.
I had a similar problem. Try using "localhost:6006" in your browser instead.
in cmd..... python -m tensorboard.main --logdir=logs/ --host localhost --port 8088
@sentdex at minute 10:59 is it overfitting?
Hello again, I have one problem. I tried this model on CPU and got 20s per epoch, then I moved it to my Tesla V100 machine and I also getting 20s per epoch :( Do you have any idea why? Tesla has been discovered properly and it's working with all drivers cudnn and all that jazz. HEEELP!!
Many problems with the terminal tensorboard logdir command. Just get list of traceback errors, ending in "_pywrap_tensorflow_internal' has no attibute 'TF_ListPysicalDevices' ". Have tried Vinny V's fix below, numerous Github / stackoverflow fixes, but no solution. Reinstalled / upgraded TF to 1.14. No solution. If anyone can suggest any fix, or resource, it'd be appreciated...thx (Update-solved via fix on Stackoverflow-
Tensorboard: OSError: [Errno 22] Invalid argument when trying to run tensorflow from command prompt
This was very helpful. How can I show an ROC curve on TensorBoard? Thank you
Nice videos, keep up the good work. If 573K joins, you should be able to add roughly 1/2 a million mugs to your collection each month.
The dream!
model.fit(X, y,
^
SyntaxError: invalid syntax
NameError: name 'model' is not defined
Please Help me :(
it shows "tensorboard' is not recognized as an internal or external command,
operable program or batch file" , does anyone know how to solve it?
if your tensorflow installation was done using conda, then you can launch tensorboard from the Anaconda prompt as follows:
activate tensorflow
tensorboard --logdir=path to your log files
@@suleimanmustafa1473
tensorboard --logdir=c:/Usarios/Javier/logs/
^
SyntaxError: invalid syntax
How can i solve it?
@@javitolez you have to run this command from the terminal
@@suleimanmustafa1473 sorry for the delay just read the answerd. I will try this and tell you how was going. Really thank very much for your answerd. Best. Javier.
is the model created gradient descent? or is it SGD?
Hi ! I have only 500+ samples in each Epoch while you have >17441, any idea why this would be the case ? I checked and the len of X is 24K so I should have all the images in the training set so why would each Epoch only treats a very small portion of it and not 66% of the total.. Any possibility to check why is that ? edit : I changed the batch size to 1 and then it treats all the data, but in this tutorial the batch size is clearly 32 so why does it still treat the whole set ?
The answer is very simple, you are a bit confused about batch size.
You'll get your answer here:
stackoverflow.com/questions/62186784/why-the-model-is-training-on-only-1875-training-set-images-if-there-are-60000-im
also if you do not mention the batch size, it is 1 by default.
@@usamatahir7091 Hi mate, thank you very much for your answer, can I assume that the situationn was different when this video was recorded ? As he always has the full scope of the samples in each epoch. I assume that something has changed in tensorflow/keras ?
@@brax86 you should try to change your tensorflow version, I had the exact same problem with tensorflow 2.3.1.. then I changed it to 2.1.0 all you need to do is !pip install tensorflow==2.1.0 and check what's gonna happen