我正在尝试建立一个完全卷积的神经网络。我的问题是,在某个阶段,张量的形状不再匹配,从而导致Exception和异常,我想在每个步骤之后打印张量的形状,以便能够指出问题所在。但是问题是,如果图形损坏并且某个时刻抛出了异常,则tf.Print似乎无法打印任何内容(即使异常发生在管道中的print语句之后)。我在打印中使用以下代码。如果我有一个有效的图形,那可以正常工作。那么,tf.Print真的只能用于工作图吗?如果是这种情况,我该如何打印张量的形状,还是使用某些调试器(例如tfdbg)的唯一可能性?
upsample = custom_layers.crop_center(input_layer, upsample)
upsample_print = tf.Print(upsample, [tf.shape(upsample)], "shape of tensor is ")
logits = tf.reshape(upsample_print, [-1, 2])
...
给出的错误是
ValueError: Dimension size must be evenly divisible by 2898844 but is 2005644 for 'gradients/Reshape_grad/Reshape' (op: 'Reshape') with input shapes: [1002822,2], [4] and with input tensors computed as partial shapes: input[1] = [?,1391,1042,2].
跃然一笑
繁星淼淼
繁星点点滴滴
随时随地看视频慕课网APP
相关分类