Tensorflow 损失函数定义
来源:互联网 发布:最新备案域名查询 编辑:程序博客网 时间:2024/05/16 05:11
import tensorflow as tffrom numpy.random import RandomStatebatch_size = 8x = tf.placeholder(tf.float32, shape=(None, 2), name='x-input')y_ = tf.placeholder(tf.float32, shape=(None, 1), name='y-input')w1 = tf.Variable(tf.random_normal([2, 1], stddev=1, seed=1))y = tf.matmul(x, w1)loss_less = 10loss_more = 1loss = tf.reduce_sum(tf.where(tf.greater(y, y_), (y - y_) * loss_more, (y_ - y) * loss_less))train_step = tf.train.AdamOptimizer(0.001).minimize(loss)rdm = RandomState(1)dataset_size = 128X = rdm.rand(dataset_size, 2)Y = [[x1 + x2 + rdm.rand()/10.0 - 0.05] for (x1, x2) in X]with tf.Session() as sess: init_op = tf.initialize_all_variables() sess.run(init_op) STEPS = 5000 for i in range(STEPS): start = (i * batch_size) % dataset_size end = min(start+batch_size, dataset_size) sess.run(train_step, feed_dict={x: X[start:end], y_: Y[start:end]}) print(sess.run(w1))
阅读全文
0 1
- Tensorflow 损失函数定义
- TensorFlow损失函数专题
- TensorFlow自定义损失函数
- tensorflow中损失函数总结
- [tensorflow损失函数系列]sigmoid_cross_entropy_with_logits
- [tensorflow损失函数系列]weighted_cross_entropy_with_logits
- [tensorflow损失函数系列]softmax_cross_entropy_with_logits
- [tensorflow损失函数系列]sparse_softmax_cross_entropy_with_logits
- Tensorflow实现经典损失函数
- TensorFlow四种损失函数
- 10、TensorFLow 中的损失函数
- tensorflow学习笔记(三):损失函数
- tensorflow框架基础之损失函数
- TensorFlow损失函数(loss function)
- tensorflow: 损失函数(Losses Functions) 探究
- TensorFlow之损失函数、学习率、正则
- tensorflow入门7 softmax函数和交叉熵损失函数
- tensorflow学习笔记(三十八):损失函数加上正则项
- DHTML技术演示---动态设置页面文字样式
- 快节奏多人在线游戏网络入门系列教程(2):客户端预测与服务器协调
- Easy-44
- TCP与SOCKET的三次握手的对应关系
- Swift 3.0 函数(Function)
- Tensorflow 损失函数定义
- 用maven创建多模块项目
- 响应式的实例
- 多重继承的内存分配
- 面试(三) 网络
- Linux nc命令详解
- 在一个Activity(Activity B)中如何关闭另一个Activity(Activity A)?
- 高并发下的数据库设计水平分区之二篇
- MySQL数据库命名规范