nfmcclure / tensorflow_cookbook

Code for Tensorflow Machine Learning Cookbook
https://www.packtpub.com/big-data-and-business-intelligence/tensorflow-machine-learning-cookbook-second-edition
MIT License
6.23k stars 2.41k forks source link

Update the weight matrix and the matrix product #175

Open JianYan-g opened 3 years ago

JianYan-g commented 3 years ago

There is no need to calculate the distance in a quadratic form by generating the diagonal matrix intermediately. Just arranging the weights as a vector and calculating the linear combination solves the calculation. This also reduces the overhead of computation because after the modification, only one matrix product need to be calculated.