Comments (8)
Thank you for the interesting question!
I'm going to examine the cause and find a solution.
But now, unfortunately, I don't have enough time, so it may take quite a while.
Could you please submit a code snippet to reproduce the error?
If you do so, we can respond relatively quickly.
Thanks!
from tf-keras-vis.
Thank you for the interesting question!
I'm going to examine the cause and find a solution.But now, unfortunately, I don't have enough time, so it may take quite a while.
Could you please submit a code snippet to reproduce the error?
If you do so, we can respond relatively quickly.Thanks!
Thank you for your quick response @keisen. Here is the gist that generates the above-mentioned error log. I hope it will help you to locate better and speed up the process :)
from tf-keras-vis.
Thank you for sharing the code!
I'm sorry for the late reply, I didn't realize your comment updated.
I've made sure that your code and improved the direct cause of the ValueError.
(The cause was that the number of loss functions that need four in that situation was just one.)
However, we are facing other error that is more complicated.
https://gist.github.com/keisen/a3b492fef779974d3e8cc07d97189afd
I'm not sure the concrete causes because I'm not familiar with YOLO, but it seems to be NOT able to calculate gradients in yolo_nms
Lambda layer.
I will find out this problem a little more, so please wait for a while.
from tf-keras-vis.
Thank you for sharing the code!
I'm sorry for the late reply, I didn't realize your comment updated.I've made sure that your code and improved the direct cause of the ValueError.
(The cause was that the number of loss functions that need four in that situation was just one.)
However, we are facing other error that is more complicated.https://gist.github.com/keisen/a3b492fef779974d3e8cc07d97189afd
I'm not sure the concrete causes because I'm not familiar with YOLO, but it seems to be NOT able to calculate gradients in
yolo_nms
Lambda layer.
I will find out this problem a little more, so please wait for a while.
Thank you very much for making an effort and helping!!
Currently, as I noticed, that you are not using the YOLOv3 loss function, however, I just would like to let you know that I realized a small mistake that I did in passing the parameters to the YOLOv3 loss function in the gist I shared above. I passed the total number of classes as classes=9
, but it should be classes=FLAGS.num_classes
. Please consider correcting this for further work.
And I am very hopeful that we will be able to make tf-keras-vis work with this state-of-the-art object detector.
Thanks :)
from tf-keras-vis.
Hi Keisen,
I just have a small update that I am successfully able to run the activation maximization with the mock loss functions you described in the gist you provided.
The model actually needed to initialize in the training mode instead of inference mode. Since yolo_boxes_0, yolo_boxes_1, yolo_boxes_2, and yolo_nms layers are just post-processing layers so they don't take part in the training and hence they don't have any gradients. Initializing the model in the training mode solves the gradient registry has no entry for: CombinedNonMaxSuppression
problem.
However, I have got another issue when running the activation maximization with the original YOLOv3 loss function.
Here is the gist that is working with mock loss functions, but I still cannot interpret the output plots. And here is the gist with the YOLOv3 loss function that reproduces the error that I am now currently facing.
In my opinion, while activation maximization (e.g. gradient ascent), loss function needs a predicted value to maximize the total loss but I am not sure. Can you please take a look in your free time?
Thanks :)
from tf-keras-vis.
Thank you for sharing your awesome work! This is the first time that I've seen the ActivaitionMaximization of YOLO.
I believe you've been almost getting the result you want. Lastly all we have to do is to define the loss (score) function to generate meaningful images.
Before I explain concretely what we should do, I have to let you know that a terminology in tf-keras-vis
have mislead you. This problem will be improved in next updates.
I believe the loss
function of tf-keras-vis
should be called score
function.
A loss function that compare model output with annotation data is used to train model. But a loss function required by tf-keras-vis just returns the score that want to maximize by ActivationMaximization.
It may be correct to be called loss
from the viewpoint of gradient decent, but it's proper to be called score
from the viewpoint of tf-keras-vis users.
So, the next step is NOT to use the YOLOv3 loss functions, but is to define the loss (score) function that returns the score corresponding to something you want to visualize.
(If there is no necessary score within a output tensor, the loss of the output return zero.)
For example, in the case of Imagenet model, when you want to visualize Ouzel (class No. 20), the score function is as follow:
def loss(output):
# output shape is (samples, 1000)
return output[:, 20]
And if the output does NOT include the necessary score:
def loss(output):
return output * 0
Please feel free to ask if you have any questions or face any errors.
Thanks!
from tf-keras-vis.
Hi Keisen, I am sorry for taking too long to write you back. I was actually stuck into something else. And thank you for explaining the loss or score function as it makes sense now. However, can you please elaborate a little on the following.
So, the next step is NOT to use the YOLOv3 loss functions, but is to define the loss (score) function that returns the score corresponding to something you want to visualize.
Let's say, for example, I want to visualize the kind of patterns and textures that the filters in Yolov3 look for an image after training. What kind of score function should I choose in this case? Any lead or help would be appreciated.
from tf-keras-vis.
I'm sorry for the late reply.
I want to visualize the kind of patterns and textures that the filters in Yolov3 look for an image after training. What kind of score function should I choose in this case?
Unfortunately, I'm not familiar with YOLO, so I don't know concretely that.
But ...
First, for visualizing the filter you want, you have to know the index of the filter in the layer outputs. (Otherwise, you have to visualize all filters one by one to find ones you want.)
Second, if the index was 10
, you have to implement the loss function such as below:
def loss(layer_output):
return layer_output[..., 10]
I hope it could help you.
Thanks!
from tf-keras-vis.
Related Issues (20)
- 'NoneType' object has no attribute 'ndim' HOT 1
- multiple inputs CNN based regression problem HOT 3
- Trouble following example using custom model, using saliency() HOT 2
- Binary Score HOT 5
- Not sure how to apply this to 3d Convolutions.
- TypeError: '<=' not supported between instances of 'int' and 'str'
- Add a Citation widget to the repo HOT 1
- Feature request: Support Python 3.10 HOT 4
- if vision transformers are supported ?
- cannot use BinaryScore HOT 3
- How to use the package with one dimensional data? HOT 1
- Problems with TF 2.9 HOT 2
- Incorrect implementation of LayerCam HOT 1
- It does not work with models with custom layers. HOT 3
- Reconstruction Error Score? HOT 2
- 'Tensor' object has no attribute 'ndim' HOT 5
- Tutorials on using 3D data
- GradCAM does not detect correct convolutional layer in multi-input case HOT 1
- Is it possible to compute the full inference at the same time as the activations? HOT 2
- value_range param is ignored
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tf-keras-vis.