問題描述,我將tensorflow1.14的代碼轉(zhuǎn)成 tensorflow2.0.2代碼是報錯出現(xiàn)了上述報錯树枫。
原因直焙,引入tensorflow庫時不一致出現(xiàn)的問題:
1.? tensorflow1.14的代碼導(dǎo)入庫如下:
2.???tensorflow2.0.0的代碼導(dǎo)入庫如下:
3.? 當我們只有部分代碼轉(zhuǎn)成 TF2.0.0的型式時,就會報錯砂轻。
如果是以上情況就會報錯如下:tensorflow.python.framework.errors_impl.FailedPreconditionError: 2 root error(s) found.
(0) Failed precondition: Error while reading resource variable BertLayer_module/bert/encoder/layer_8/attention/self/key/kernel from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/BertLayer_module/bert/encoder/layer_8/attention/self/key/kernel/N10tensorflow3VarE does not exist.
[[{{node BertLayer/BertLayer_module_apply_tokens/bert/encoder/layer_8/attention/self/key/MatMul/ReadVariableOp}}]]
[[loss/Identity/_319]]
(1) Failed precondition: Error while reading resource variable BertLayer_module/bert/encoder/layer_8/attention/self/key/kernel from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/BertLayer_module/bert/encoder/layer_8/attention/self/key/kernel/N10tensorflow3VarE does not exist.
[[{{node BertLayer/BertLayer_module_apply_tokens/bert/encoder/layer_8/attention/self/key/MatMul/ReadVariableOp}}]]
0 successful operations.
0 derived errors ignored.
要解決該問題就應(yīng)用將全部程序轉(zhuǎn)換成TF2.0的型式奔誓。