Tensorflow Colab资源和自我注意(分配张量时为OOM)

Tensorflow Colab资源和自我注意(分配张量时为OOM),tensorflow,keras,google-colaboratory,generative-adversarial-network,attention-model,Tensorflow,Keras,Google Colaboratory,Generative Adversarial Network,Attention Model,我正试图用Keras在google Colab上实现一个自我关注的GAN。当我测试我的注意力层时,我有一个OOM错误。那么,我是不是在矩阵乘法方面做错了什么,或者对于更高分辨率(>64 x 64)的colab GPU来说,这是一个过于昂贵的操作 这就是测试: tensor = np.random.normal(0, 1, size=(32, 64, 64, 512)).astype('float64') attention_o = SelfAttention(64) a = attention_

我正试图用Keras在google Colab上实现一个自我关注的GAN。当我测试我的注意力层时,我有一个OOM错误。那么,我是不是在矩阵乘法方面做错了什么,或者对于更高分辨率(>64 x 64)的colab GPU来说,这是一个过于昂贵的操作

这就是测试:

tensor = np.random.normal(0, 1, size=(32, 64, 64, 512)).astype('float64')
attention_o = SelfAttention(64)
a = attention_o.attentionMap(tensor)
这就是错误:

OOM when allocating tensor with shape[32,4096,4096] and type double

非常感谢您的关注:您的大小为32x4096x4096的张量有536870912个条目!这个,乘以一个double(8)中的字节数,转换成Gb就是4294!这是超过4Tb,绝对不适合在一个GPU。在应用自我关注之前,您可能需要添加几个最大池层以降低数据的维度。

因此,如果我想在生成器(128x128)的末尾应用自我关注层,我必须,例如:使用最大池两次(32x32)->应用关注->上采样(128x128)。这有意义吗?谢谢你的耐心是的,就是这个主意。我肯定会在每次最大池操作之前应用一些卷积层,这样神经网络就可以学习数据的压缩表示。
OOM when allocating tensor with shape[32,4096,4096] and type double