How to get all the weight updates from Word2Vec [closed] - tensorflow

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am not only interested in the final W0 and W1 (also, to some known as W and W'), but all the variations of these two matrices during the learning.
For now, I am using the gensim implementation, but compared to sklearn, gensim's API is not very well organized in my mind. Hence, I am open to moving to tf if need be, given that getting access to these values would be possible/easier.
I know I can hack the main code; my question is whether there already is a function/variable for it.

There's no specific API for seeing individual training example updates, or interim weights mid-training.
But as you've intuited, instead of calling train() once, letting it run all epochs and all learning-rate-updates (as is recommended), you could call it one epoch at a time, providing it the right incremental start_alpha and end_alpha yourself each call, and between the calls look at the word-vectors (aka "projection weights") and hidden-to-output weights (syn1neg for default negative-sampling, or syn1 for hierarchical-softmax).
If you needed more fine-grained reporting, you'd need to modify the source code to add the extra logging/callouts/etc you need.

Related

predict the position of an image in another image [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
If one image is a part of another image, then how to compute the accurate location in deep learning way?
Now I could compute this by extracting and matching key points using OpenCV, but I hope to solve it with neural networks.
Any ideas to design the networks and loss functions?
Thanks very much.
This is a detection problem. The simplest approach to do it is to create a a network with two heads, one for classification and the other for the bounding box (regression).
you feed your network with the image and respective label, and sum the lossess and do a backward. train for some epochs and you'll get your self a detection model that you can use to detect what you need. but its just a simple approach and it can get much more complex.
You may as well skip this and use an existing detection architecture or better framework which simplifies your life much better.
For Tensorflow I belive you can use ObjectDetctionAPI and for Pytorch you can use Detectron, Detectron2, mmdetection among others.

Semantic Segmentation with a dominant class [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am training a semantic segmentation model consists of 3 classes(counting with the background).
The background is the dominant class, and the problem is that the model predicts every pixel as background.
I am currently using cross entropy loss function.
What are the solutions for this situation?
This is a typical strong imbalance for image segmentation; down below there are a couple of solutions to tackle this problem.
Use Jaccard(IoU) loss or dice loss; rather than optimizing for accuracy, you will optimise for the intersection over union, for example, and it has been demonstrated that they work much better than cross_entropy in case of imbalanced problems.
You may try to use class weights(sample weights in Keras/TF) in order to assign a greater importance for class 2 and 3 which are not background.
The Focal Loss has shown improvements in MLPs or other deep learning tasks, in which the dataset is strongly imbalanced. Focal loss can be combined with a loss from (1) and (3); it has the potential to improve your results.
You should expect to get the best performance improvement by employing (1) alone.

why can't I reimplement my tensorflow model with pytorch? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I am developing a model in tensorflow and find that it is good on my specific evaluation method. But when I transfer to pytorch, I can't achieve the same results. I have checked the model architecture, the weight init method, the lr schedule, the weight decay, momentum and epsilon used in BN layer, the optimizer, and the data preprocessing. All things are the same. But I can't get the same results as in tensorflow. Anybody have met the same problem?
I did a similar conversion recently.
First you need to make sure that the forward path produces the same results: disable all randomness, initialize with the same values, give it a very small input and compare. If there is a discrepancy, disable parts of the network and compare enabling layers one by one.
When the forward path is confirmed, check the loss, gradients, and updates after one forward-backward cycle.

Machine Learning & Image Recognition: How to start? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I've been a full stack web developer for 15 years now and would like to be involved in machine learning. There is already a specific scenario for this: We have a database with several million products and one product image each. There is also a database with about 5000 terms.
A product image is linked to several terms (usually 3 - 20), whereby the link still has a weighting (1-100%). The terms are always of a visual nature, that is, they describe a visually recognizable feature on the image.
The aim should now be to upload a new image (of course with thematic reference) and to get an answer with possible terms (including probability) based on the already classified images.
Do you have any advice on how best to start here? Is there a framework that comes close to this scenario? Is TensorFlow relevant for this task? What new language should I learn?
Thank you very much!
TensorFlow can be used, it's pretty "low-level" though. So if you're just starting out you might be better off using Keras with a TensorFlow backend as it's more userfriendly.
Regarding languages you will probably use Python. So if you don't know it already you should get started. In my opinion you can also learn it on-the-fly while practicing as you're already a developer.
As for tutorials you will have to probably pick out the relevant bits of many different tutorials. You could get started with something like this:
https://www.pyimagesearch.com/2018/05/07/multi-label-classification-with-keras/

Any way to manually make a variable more important in a machine learning model? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Sometimes you know by experience or by some expert knowledge some variable will play a key role in this model, is there a way to manually make the variable count more so the training process can speed up and the method can combine some human knowledge/wisdom/intelligence.
I still think machine learning combined with human knowledge is the strongest weapon we have now
This might work by scaling your input data accordingly.
On the other hand the strength of a neural network is to figure out
which features are in fact important and which combinations with other
features are important - from the data.
You might argue, that you'll decrease training time. Somebody else might argue that you're biasing your training in such a way that it might even take more time.
Anyway if you would want to do this, assuming a fully connected layer, you could increasedly initialize the weights of the input feature you found important.
Another way, could be to first pretrain the model according to a training loss, that should have your feature as an output. Than keep the weights and switch to the actual loss - I have never tried this, but it could work.