Tensorflow中的参数数量与内存使用量之间有什么关系?

时间:2019-02-26 02:29:47

标签: python tensorflow

我正在Tensorflow中尝试一些图像超分辨率CNN。最初,我使用一个密集的网(总共2276060个参数)作为模型,并且运行良好。然后,我将模型更改为参数较少(总计951425)的修改后的DBPN,并遇到错误:

tensorflow.python.framework.errors_impl.InternalError: Dst tensor is not initialized.

这是根据this answer的内存不足引起的。

我很困惑,为什么较小的模型却导致较大的内存消耗?我能弄清楚的唯一原因是DBPN具有比密集网络更多的Ops。 Tensorflow是否根据Ops的数量而不是参数的数量分配内存?

我使用的两个模型的结构和参数如下:

密集网:

param   0: Interp/shallow1/W_conv3d:0 (3, 3, 3, 1, 64)    float32_ref
param   1: Interp/shallow1/b_conv3d:0 (64,)              float32_ref
param   2: Interp/shallow2/W_conv3d:0 (3, 3, 3, 64, 64)    float32_ref
param   3: Interp/shallow2/b_conv3d:0 (64,)              float32_ref
param   4: Interp/rdb1/conv1/W_conv3d:0 (3, 3, 3, 64, 64)    float32_ref
param   5: Interp/rdb1/conv1/b_conv3d:0 (64,)              float32_ref
param   6: Interp/rdb1/conv2/W_conv3d:0 (3, 3, 3, 128, 64)    float32_ref
param   7: Interp/rdb1/conv2/b_conv3d:0 (64,)              float32_ref
param   8: Interp/rdb1/conv3/W_conv3d:0 (3, 3, 3, 192, 64)    float32_ref
param   9: Interp/rdb1/conv3/b_conv3d:0 (64,)              float32_ref
param  10: Interp/rdb1/conv4/W_conv3d:0 (1, 1, 1, 256, 64)    float32_ref
param  11: Interp/rdb1/conv4/b_conv3d:0 (64,)              float32_ref
param  12: Interp/rdb2/conv1/W_conv3d:0 (3, 3, 3, 64, 64)    float32_ref
param  13: Interp/rdb2/conv1/b_conv3d:0 (64,)              float32_ref
param  14: Interp/rdb2/conv2/W_conv3d:0 (3, 3, 3, 128, 64)    float32_ref
param  15: Interp/rdb2/conv2/b_conv3d:0 (64,)              float32_ref
param  16: Interp/rdb2/conv3/W_conv3d:0 (3, 3, 3, 192, 64)    float32_ref
param  17: Interp/rdb2/conv3/b_conv3d:0 (64,)              float32_ref
param  18: Interp/rdb2/conv4/W_conv3d:0 (1, 1, 1, 256, 64)    float32_ref
param  19: Interp/rdb2/conv4/b_conv3d:0 (64,)              float32_ref
param  20: Interp/rdb3/conv1/W_conv3d:0 (3, 3, 3, 64, 64)    float32_ref
param  21: Interp/rdb3/conv1/b_conv3d:0 (64,)              float32_ref
param  22: Interp/rdb3/conv2/W_conv3d:0 (3, 3, 3, 128, 64)    float32_ref
param  23: Interp/rdb3/conv2/b_conv3d:0 (64,)              float32_ref
param  24: Interp/rdb3/conv3/W_conv3d:0 (3, 3, 3, 192, 64)    float32_ref
param  25: Interp/rdb3/conv3/b_conv3d:0 (64,)              float32_ref
param  26: Interp/rdb3/conv4/W_conv3d:0 (1, 1, 1, 256, 64)    float32_ref
param  27: Interp/rdb3/conv4/b_conv3d:0 (64,)              float32_ref
param  28: Interp/gff/conv1/W_conv3d:0 (1, 1, 1, 192, 64)    float32_ref
param  29: Interp/gff/conv1/b_conv3d:0 (64,)              float32_ref
param  30: Interp/gff/conv2/W_conv3d:0 (3, 3, 3, 64, 64)    float32_ref
param  31: Interp/gff/conv2/b_conv3d:0 (64,)              float32_ref
param  32: Interp/out/W_conv3d:0 (3, 3, 3, 1, 1)    float32_ref
param  33: Interp/out/b_conv3d:0 (1,)               float32_ref
num of params: 2276060

DBPN

param   0: Interp/feat0/W_conv3d:0 (3, 3, 3, 1, 64)    float32_ref
param   1: Interp/feat0/b_conv3d:0 (64,)              float32_ref
param   2: Interp/feat1/W_conv3d:0 (1, 1, 1, 64, 32)    float32_ref
param   3: Interp/feat1/b_conv3d:0 (32,)              float32_ref
param   4: Interp/up1/deconv1/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param   5: Interp/up1/deconv1/b_deconv3d:0 (32,)              float32_ref
param   6: Interp/up1/conv/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param   7: Interp/up1/conv/b_conv3d:0 (32,)              float32_ref
param   8: Interp/up1/deconv2/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param   9: Interp/up1/deconv2/b_deconv3d:0 (32,)              float32_ref
param  10: Interp/down1/conv1/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  11: Interp/down1/conv1/b_conv3d:0 (32,)              float32_ref
param  12: Interp/down1/deconv/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  13: Interp/down1/deconv/b_deconv3d:0 (32,)              float32_ref
param  14: Interp/down1/conv2/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  15: Interp/down1/conv2/b_conv3d:0 (32,)              float32_ref
param  16: Interp/up2/deconv1/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  18: Interp/up2/conv/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  19: Interp/up2/conv/b_conv3d:0 (32,)              float32_ref
param  20: Interp/up2/deconv2/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  21: Interp/up2/deconv2/b_deconv3d:0 (32,)              float32_ref
param  22: Interp/down2/conv/W_conv3d:0 (1, 1, 1, 64, 32)    float32_ref
param  23: Interp/down2/conv/b_conv3d:0 (32,)              float32_ref
param  24: Interp/down2/down_conv1/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  25: Interp/down2/down_conv1/b_conv3d:0 (32,)              float32_ref
param  26: Interp/down2/down_conv2/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  27: Interp/down2/down_conv2/b_deconv3d:0 (32,)              float32_ref
param  28: Interp/down2/down_conv3/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  29: Interp/down2/down_conv3/b_conv3d:0 (32,)              float32_ref
param  30: Interp/up3/conv/W_conv3d:0 (1, 1, 1, 64, 32)    float32_ref
param  31: Interp/up3/conv/b_conv3d:0 (32,)              float32_ref
param  32: Interp/up3/up_conv1/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  33: Interp/up3/up_conv1/b_deconv3d:0 (32,)              float32_ref
param  34: Interp/up3/up_conv2/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  35: Interp/up3/up_conv2/b_conv3d:0 (32,)              float32_ref
param  36: Interp/up3/up_conv3/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  37: Interp/up3/up_conv3/b_deconv3d:0 (32,)              float32_ref
param  38: Interp/down3/conv/W_conv3d:0 (1, 1, 1, 96, 32)    float32_ref
param  39: Interp/down3/conv/b_conv3d:0 (32,)              float32_ref
param  40: Interp/down3/down_conv1/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  41: Interp/down3/down_conv1/b_conv3d:0 (32,)              float32_ref
param  42: Interp/down3/down_conv2/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  43: Interp/down3/down_conv2/b_deconv3d:0 (32,)              float32_ref
param  44: Interp/down3/down_conv3/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  45: Interp/down3/down_conv3/b_conv3d:0 (32,)              float32_ref
param  46: Interp/up4/conv/W_conv3d:0 (1, 1, 1, 96, 32)    float32_ref
param  47: Interp/up4/conv/b_conv3d:0 (32,)              float32_ref
param  48: Interp/up4/up_conv1/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  49: Interp/up4/up_conv1/b_deconv3d:0 (32,)              float32_ref
param  50: Interp/up4/up_conv2/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  51: Interp/up4/up_conv2/b_conv3d:0 (32,)              float32_ref
param  52: Interp/up4/up_conv3/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  53: Interp/up4/up_conv3/b_deconv3d:0 (32,)              float32_ref
param  54: Interp/down4/conv/W_conv3d:0 (1, 1, 1, 128, 32)    float32_ref
param  55: Interp/down4/conv/b_conv3d:0 (32,)              float32_ref
param  56: Interp/down4/down_conv1/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  57: Interp/down4/down_conv1/b_conv3d:0 (32,)              float32_ref
param  58: Interp/down4/down_conv2/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  59: Interp/down4/down_conv2/b_deconv3d:0 (32,)              float32_ref
param  60: Interp/down4/down_conv3/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  61: Interp/down4/down_conv3/b_conv3d:0 (32,)              float32_ref
param  62: Interp/up5/conv/W_conv3d:0 (1, 1, 1, 128, 32)    float32_ref
param  63: Interp/up5/conv/b_conv3d:0 (32,)              float32_ref
param  64: Interp/up5/up_conv1/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  65: Interp/up5/up_conv1/b_deconv3d:0 (32,)              float32_ref
param  66: Interp/up5/up_conv2/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  67: Interp/up5/up_conv2/b_conv3d:0 (32,)              float32_ref
param  68: Interp/up5/up_conv3/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  69: Interp/up5/up_conv3/b_deconv3d:0 (32,)              float32_ref
param  70: Interp/down5/conv/W_conv3d:0 (1, 1, 1, 160, 32)    float32_ref
param  71: Interp/down5/conv/b_conv3d:0 (32,)              float32_ref
param  72: Interp/down5/down_conv1/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  73: Interp/down5/down_conv1/b_conv3d:0 (32,)              float32_ref
param  74: Interp/down5/down_conv2/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  75: Interp/down5/down_conv2/b_deconv3d:0 (32,)              float32_ref
param  76: Interp/down5/down_conv3/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  77: Interp/down5/down_conv3/b_conv3d:0 (32,)              float32_ref
param  78: Interp/up6/conv/W_conv3d:0 (1, 1, 1, 160, 32)    float32_ref
param  79: Interp/up6/conv/b_conv3d:0 (32,)              float32_ref
param  80: Interp/up6/up_conv1/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  81: Interp/up6/up_conv1/b_deconv3d:0 (32,)              float32_ref
param  82: Interp/up6/up_conv2/W_conv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  83: Interp/up6/up_conv2/b_conv3d:0 (32,)              float32_ref
param  84: Interp/up6/up_conv3/W_deconv3d:0 (3, 3, 3, 32, 32)    float32_ref
param  85: Interp/up6/up_conv3/b_deconv3d:0 (32,)              float32_ref
param  86: Interp/output_conv/W_conv3d:0 (3, 3, 3, 192, 1)    float32_ref
param  87: Interp/output_conv/b_conv3d:0 (1,)               float32_ref
num of params: 951425

0 个答案:

没有答案