'calculate weighted average in pytorch

How to calculate the average weighted by neural networks in PyTorch?

I need to code c enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source