tensorflow 报错内容总结

来源:互联网 发布:知米软件取英文名 编辑:程序博客网 时间:2024/04/30 01:26

tensorflow 报错内容总结

一,版本更新问题引起的

1.’tf.stack()’替代’tf.pack(value,axis,name)’

    import tensorflow as tf    a = tf.constant([1,2,3])    a = tf.constant([4,5,6])    c = tf.stack([a,b],axis = 1)    d = tf.unstack(c,axis = 0)    e = tf.unstack(c,axis = 1)`    with tf.Session() as sess:        print(sess.run(c))        print(sess.run(d))        print(sess.run(e))

结果为[[1,4]
[2,5]
[3,6]]
[array([1,4]),array([2,5]),array([3,6])]
[array([1,2,3]),array([4,5,6])]
*****************

2,交叉熵函数

tf.tf.nn.softmax_cross_entropy_with_logits(labels=y,logits = _pred)
labels= 和 logits= 一定要加上,不然会报错!!!

3,

二,常见错误

1,模型的保存和加载

tf.train.Saver(max_step = 3).save(sess,path)
tf.train.Saver(max_step = 3).restore(sess,path)
path,要先在路径上创建好存储的文件夹,不然会报错!!!

原创粉丝点击