我有这个问题,在一次迭代后,几乎所有的参数(成本函数,权重,假设函数等)都输出'NaN'.我的代码类似于张量流教程MNIST-Expert(https://www.tensorflow.org/versions/r0.9/tutorials/mnist/pros/index.html).我已经寻找解决方案,到目前为止我尝试过:将学习率降低到接近零并将其设置为零,使用AdamOptimizer而不是梯度下降,使用sigmoid函数作为最后一层中的假设函数并仅使用numpy函数.我的输入数据中有一些负值和零值,因此我不能使用对数交叉熵而不是二次成本函数.结果是一样的,但我的输入数据包括土壤的应力和应变.
import tensorflow as tf
import Datafiles3_pv_complete as soil
import numpy as np
m_training = int(18.0)
m_cv = int(5.0)
m_test = int(5.0)
total_examples = 28
" range for running "
range_training = xrange(0,m_training)
range_cv = xrange(m_training,(m_training+m_cv))
range_test = xrange((m_training+m_cv),total_examples)
""" Using interactive Sessions"""
sess = tf.InteractiveSession()
""" creating input and output vectors """
x = tf.placeholder(tf.float32, shape=[None, 11])
y_true = tf.placeholder(tf.float32, shape=[None, 3])
""" Standard Deviation Calculation"""
stdev = np.divide(2.0,np.sqrt(np.prod(x.get_shape().as_list()[1:])))
""" Weights and Biases """
def weights(shape):
initial …Run Code Online (Sandbox Code Playgroud)