ImagesLoss
See original GitHub issueHi,
I’m very excited about this work! I was wondering if ImagesLoss
with Sinkhorn divergence would be usable (when it’s ready) as a reconstruction loss for an image autoencoder for representation learning?
Pseudocode to code to illustrate what I was thinking about:
encoder = ConvNet()
decoder = DeconvNet()
optimizer = Optimizer(chain(encoder.parameters(), decoder.parameters()))
loss_fn = ImagesLoss(loss="sinkhorn", p=2, blur=.05)
for images in dataset:
optimizer.zero_grad()
encoding = encoder(images)
image_preds = decoder(encoding)
loss = loss_fn(images, image_preds)
loss.backward()
optimizer.step()
Thanks, Agost
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Loss Pictures | Download Free Images on Unsplash
Download the perfect loss pictures. Find over 100+ of the best free loss images. Free for commercial use ✓ No attribution required ✓...
Read more >Loss Pictures, Images and Stock Photos - iStock
Browse 502,301 loss stock photos and images available, or search for grief or business loss to find more great stock photos and pictures....
Read more >Loss Pictures, Photos, Images, and Pics for ... - LoveThisPic
Looking for the best loss pictures, photos & images? LoveThisPic's pictures can be used on Facebook, Tumblr, Pinterest, Twitter and other websites.
Read more >37704 Grief And Loss Images, Stock Photos & Vectors
Find Grief And Loss stock images in HD and millions of other royalty-free stock photos, illustrations and vectors in the Shutterstock collection.
Read more >1,000+ Free Loss & Weight Loss Images - Pixabay
Loss images for free download. Browse or use the filters to find your next picture for your project. Diet, Vernier, Sandwich, Calorie Counter....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @abiro ,
Sure! However, please keep in mind that OT theory is always concerned with measures, distributions of mass. In your example,
loss_fn(images, images_preds)
would return a vector of Wasserstein-like distances between each pair of original and encoded-decoded image, all of them being understood as density maps that represent measures in the rectangular image domain. (As a side note, before doing a.backward()
, you would have to add aloss = loss.sum()
.) Consequently,ImagesLoss
andVolumesLoss
will be best suited to the processing of segmentation masks in medical imaging and computer vision.Note that using OT on raw image data is asking for trouble: measure theory handles “black” and “white” as “absence” and “presence” of mass, which is rarely what researchers want to do with natural images. Fortunately, as discussed for instance in the color transfer tutorial, you can perfectly represent an image as a point cloud in some arbitrary feature space, and use SamplesLoss to define a relevant processing. In your example, a simple way of defining a transport-based loss functions between two “natural” images is to represent them as point clouds
(x, y, r, g, b)
in R^5 and feed them toSamplesLoss
. Of course, you could then tune the ratio between the “geometric features”(x, y)
and the color coordinates(r, g, b)
or use a perceptual color space to improve your results.Best regards,
Jean
Hi @jeanfeydy ,
Thanks for your quick and detailed reply very much.
I’m confused when comparing the above
to_pointcloud
function andRGB_cloud
function in the color transfer demo.If inputting a commonly used
RGB 2D
/CT 3D
image with shape=(256,256,3)
or(512,512,100)
, respectively, the expected point cloud outputs are (x, y, r, g, b), (x, y, z, CT_value), right?However, for the function
RGB_cloud
, the output shape is (256256, 3), while the output shape ofto_pointcloud
is (256256, 2). I’m confused about the differences.Specifically, I want to use the Wasserstein distance in the following two settings.
1. compute the Wasserstein distance between the label and softmax outputs
Question: how should I pass the
outputs_soft
andlabel_batch
into theloss_fn
?2. compute the Wasserstein distance between two distance maps
L1/L2 norm and KL-divergence is commonly used in this setting. Now, I want to try Wasserstein distance.
Question: how should I pass the
outputs
andlabel_distance_map
into the loss_fn?Looking forward to your reply at your convenience.
Best regards, Jun