Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are some python variables uppercase whereas others are lowercase?

I often see uppercase and lowercase single character variables. I’m not sure if the case is chosen because the variable is an instance of a class, float32, or just personal preference.

Here is an example from Tensorflow's getting started guide. https://www.tensorflow.org/get_started/get_started

W = tf.Variable([.3], dtype=tf.float32)
b = tf.Variable([-.3], dtype=tf.float32)
x = tf.placeholder(tf.float32)
linear_model = W * x + b

I'm trying to understand if there is a specific reason why W is capitalized whereas b is lowercase when both are of the same type.

like image 768
Charles Green Avatar asked Oct 20 '17 03:10

Charles Green


1 Answers

It's probably not a reflection of Python per se but of the math it captures. Usually the coefficients on x is a matrix which has a convention of being an uppercase variable. That this is a 1-dimensional example you're seeing obscures this convention, higher dimensions would be more telling.

like image 150
jxramos Avatar answered Sep 25 '22 01:09

jxramos