首页 > 解决方案 > FailedPreconditionError:从容器读取资源变量 _AnonymousVar54 时出错:本地主机

问题描述

我在 google colab 上运行代码,其中数据集是我自己的,即 X_train(我上传),图像大小为 15x15(我在代码中更改了,在需要的地方。为了保存输出图像,更改了位置。还有更多参数变化是 epochs=40000, batch_size=10, sample_interval=2000

我收到以下错误,并且只保存了一张图像:

/usr/local/lib/python3.6/dist-packages/keras/engine/training.py:297: UserWarning: Discrepancy between trainable weights and collected trainable weights, did you set `model.trainable` without calling `model.compile` after ?
  'Discrepancy between trainable weights and collected trainable'
0 [D loss: 0.999931] [G loss: 1.000150]
---------------------------------------------------------------------------
FailedPreconditionError                   Traceback (most recent call last)
<ipython-input-4-caa940a5773c> in <module>()
      2 if __name__ == '__main__':
      3     wgan = WGAN()
----> 4 wgan.train(epochs=40000, batch_size=10, sample_interval=2000)

________________________________________
7 frames
________________________________________
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
     58     ctx.ensure_initialized()
     59     tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 60                                         inputs, attrs, num_outputs)
     61   except core._NotOkStatusException as e:
     62     if name is not None:

FailedPreconditionError:  Error while reading resource variable _AnonymousVar54 from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/_AnonymousVar54/N10tensorflow3VarE does not exist.
     [[node mul_12/ReadVariableOp (defined at /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3009) ]] [Op:__inference_keras_scratch_graph_4664]

Function call stack:
keras_scratch_graph

标签: google-colaboratorygenerative-adversarial-network

解决方案


推荐阅读