损失函数的三种定义方式:
- mse:mean squared error
- crossentropy
- 自定义
均方误差法:
loss_mse=tf.reduce_mean(tf.square(y_-y)
tensorflow中的一个预测函数 :
tf.where(tf.greater(a,b), C ,D)
this is a simple way to realize the discription of judgement and a selected output. If a>b, the output is C. Otherwise, the output is D.
下面开始一个酸奶销量神经网络预测:
在实际生产生活过程中,假设一个成本为2元,并且利润为1。来进行预测。
import tensorflow as tf
import numpy as np
SEED = 23455
COST =2
PROFIT = 1
rdm = np.random.RandomState(SEED)
x = rdm.rand