![](/img/trans.png)
[英]How to get reproducible results using tensorflow-gpu in CNN model?
[英]In TensorFlow, how to clear the GPU memory of an intermediate variable in a CNN model?
我只是使用TensorFlow来实现CNN模型。 在训练过程中,有一个中间变量占用较大的GPU内存,我想清除该变量的内存。
此变量称为'rgb_concat',我只是尝试使用'rgb_concat = []'清除其内存,不确定是否在TensorFlow中有用?
我如何在TensorFlow中实现这一目标? 提前致谢!
一个名为“ rgb_concat”的中间变量,它占用较大的GPU内存,我想清除它并为CNN模型中的其他层保存GPU内存。 如何在TensorFlow中实现它?
x = input_image
for j in range(n_sub_layers):
nn = Conv2dLayer(x, j) #
rgb_concat.append(nn)
x = nn
rgb_concat_sublayer = ConcatLayer([rgb_concat[0], rgb_concat[1]], concat_dim=3, name='rgb_concat_sublayer_{}_{}'.format(i,1))
for sub_layer in range(2, n_sub_layers): #Second 'for' loop!!!
rgb_concat_sublayer = ConcatLayer([rgb_concat_sublayer, rgb_concat[sub_layer]], concat_dim=3, name='rgb_concat_sublayer_{}_{}'.format(i,sub_layer))
由于在第二个“ for”循环之后不再需要“ rgb_concat”,因此应在“ for”循环后将其清除。
您是否尝试过del关键字?
del rgb_concat
您也可以将变量设置为“无”。
rgb_concat = None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.