【问题标题】:Very large networks in tensorflow张量流中非常大的网络
【发布时间】:2018-02-15 16:37:17
【问题描述】:
我正在尝试在 tensorflow 中训练神经网络,但我的权重数组足够大,以至于我遇到了 2GB GraphDef 的限制。在这种情况下,我最好的办法是什么?
注意:我真的没有使用 tensorflow 的全部功能(例如,我的网络没有优化器)。相反,我只是使用 tensorflow 作为在 GPU 上执行一些基本数组操作的一种方式。
【问题讨论】:
标签:
memory
tensorflow
neural-network
gpu
【解决方案1】:
您可能不小心用一个大常数初始化了一个 tf.Variable。见https://github.com/tensorflow/tensorflow/issues/2382
github 问题的解决方法:
init_val = np.array(...) # Construct a large numpy array.
init_placeholder = tf.placeholder(tf.float32, shape=init_val.shape)
v = tf.Variable(init_placeholder)
# ...
sess.run(v.initializer, feed_dict={init_placeholder: init_val})