why do we call the first element for reshaping when x_train has 2 elements.

the output is: tf.Tensor([[1.28]], shape=(1, 1), dtype=float32)
Why does it output a tensor with the value 1.28 when x_train[0] is [1.0]
What is more confusing is that when I refresh the webpage and re-run the cells, tensor value changes. IT seems to be a some random float number assigned by tensorflow.

1. why do we call the first element for reshaping when x_train has 2 elements.

I think this is just to keep the example very simple. It shows that evaluating a single example is enough to instantiate the weights. And when you print a1, it shows just the one value: the result of the linear expression evaluated for the first example, where x=1.0.

2. the output is: tf.Tensor([[1.28]], shape=(1, 1), dtype=float32)
Why does it output a tensor with the value 1.28 when x_train[0] is [1.0]
What is more confusing is that when I refresh the webpage and re-run the cells, tensor value changes. IT seems to be a some random float number assigned by tensorflow.

linear_layer will evaluate wx + b where x = x_train[0] = 1.0, so the 1.28 you’re seeing is the result of this calculation. You’re exactly right that the result will be random since the weights are randomly initialized. This is explained in the next cell where it says:

Now let's look at the weights and bias. These weights are randomly initialized to small numbers and the bias defaults to being initialized to zero.

You’ll see in the following cells how you can initialize w and b with your own initial values if you choose.