Using tf.matmul vs


Quick question

In the tutorials, for instance, in the bayesian linear regression, the model is defined as

y = Normal(, w) + b, scale=1.0)

however for a multiple output case, w is a matrix and one no longer multiplies a matrix by a vector.

My question is is there any reason not to use tf.matmul instead of Looking at the source it seems like it is more of a convenience function wrapping tf.matmul if the input isn’t formatted as a matrix and has NaNs or Infs with


x = control_flow_ops.with_dependencies(dependencies, x)

Is there any reason, assuming you already know your input data is going to be valid, to simply use tf.matmul.
For instance, if your data has NaNs or Infs then the dot product won’t work in the first place and something will break anyway. So it appears to be primarily for logging purposes.
I might be missing something subtle however

So instead is it perfectly fine to use something like

y = Normal(loc=tf.matmul(X, w) + b, scale=1.0)



You are correct. is a convenience function for matrix-vector products. tf.matmul works only on matrices and returns a matrix. If w and y are indeed both matrices as in your setting, then tf.matmul is more appropriate.


awesome, thanks dustin