Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 如何为TensorFlow中的CNNs算法开发随机梯度下降优化器?_Python 2.7_Tensorflow_Deep Learning - Fatal编程技术网

Python 2.7 如何为TensorFlow中的CNNs算法开发随机梯度下降优化器?

Python 2.7 如何为TensorFlow中的CNNs算法开发随机梯度下降优化器?,python-2.7,tensorflow,deep-learning,Python 2.7,Tensorflow,Deep Learning,我在CNNs、python中使用TensorFlow库 我想为CNNs优化器开发一个随机梯度下降优化器,参数如下: learning rate = 0.05, decay = 1e-6, Nesterov momentum 0.9 我想知道我应该如何改变我的代码来实现这一点。以下是我目前掌握的代码: optimizer = tf.train.AdamOptimizer(learning_rate=0.05).minimize(cost) 谢谢。这可以通过使用动量优化器()和指数衰减()轻松

我在CNNs、python中使用TensorFlow库

我想为CNNs优化器开发一个随机梯度下降优化器,参数如下:

learning rate = 0.05,
decay = 1e-6, 
Nesterov momentum 0.9
我想知道我应该如何改变我的代码来实现这一点。以下是我目前掌握的代码:

optimizer = tf.train.AdamOptimizer(learning_rate=0.05).minimize(cost)

谢谢。

这可以通过使用动量优化器()和指数衰减()轻松实现:


我使用您的算法,但代价函数返回nan值。这是我的成本函数:cost=tf.reduce\u mean(tf.nn.softmax\u cross\u entropy\u with\u logits(logits=pred,labels=y))是的,这是与adam合作的,但当我使用动量时,这是我的结果:Iter 88320,小批量损耗=nan,训练精度=0.03125/////Iter 89600,小批量损耗=nan,训练精度=0.02344 Hanks Thomas当我更改衰减值时,它变为OK。谢谢你的帮助
global_step = tf.Variable(0, trainable=False)
starter_learning_rate = 0.05
learning_rate = tf.train.exponential_decay(starter_learning_rate, global_step,
                                       1000, 0.96, staircase=True)

optimizer = tf.train.MomentumOptimizer(learning_rate=learning_rate, momentum=0.9, use_nesterov=True).minimize(cost, global_step=global_step)