十.Tensorflow反向传播

A Regression Example

We create a regression example as follows. The input data will be 100 random samples from a normal (mean of 1.0, stdev of 0.1). The target will be 100 constant values of 10.0.

We will fit the regression model: x_data * A = target_values

Theoretically, we know that A should be equal to 10.0.

We start by creating the data and targets with their respective placholders

Classification Example

For the classification example, we will create an x-sample made of two different normal distribution inputs, Normal(mean = -1, sd = 1) and Normal(mean = 3, sd = 1). For each of these the target will be the class 0 or 1 respectively.

The model will fit the binary classification: If sigmoid(x+A) < 0.5 then predict class 0, else class 1.

Theoretically, we know that A should take on the value of the negative average of the two means: -(mean1 + mean2)/2.

We start by resetting the computational graph:

你可能感兴趣的:(十.Tensorflow反向传播)