繁体   English   中英

Tensorflow 在模型内应用操作:FailedPreconditionError

[英]Tensorflow applying operations inside a model: FailedPreconditionError

假设我有 CNN 模型,它以类似 Unet 的方式输出 N 个概率图作为与输入图像大小相同的掩码。 然后我想在每个掩码的顶部应用例如最小二乘拟合来获取函数的系数作为输出,并使用这些来计算我的模型损失。

def unet_model(...)
    # init unet model
    ...
    ...
    # final layer
    mask_out = layers.Conv2D(output_channels, (1,1), activation='softmax')(conv9)

    # start applying e.g least squares fit here
    eq_list = tf.Variable((x_map, y_map, mask_out))
    transp = tf.transpose(a)
    ...

当我初始化模型时,transp 会出现以下错误。 我已经在其他地方测试了最小二乘拟合操作。

FailedPreconditionError: Error while reading resource variable _AnonymousVar1423 from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/_AnonymousVar1423/N10tensorflow3VarE does not exist. name: transpose/

我有一些假设,例如转置无法处理批量大小的占位符轴,但通常对此一无所知。

在添加每个变量之前,我需要确保 x_map 和 y_map 也通过扩展轴 -1 的暗度进行批处理

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM