我构建了一个非常简单的带有单个密集层的 TensorFlow Keras 模型。它在块外工作得很好GradientTape,但在GradientTape块内它会引发LookupError: No gradient defined for operation 'IteratorGetNext' (op type: IteratorGetNext)
重现代码:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
import tensorflow as tf
import numpy as np
print(tf.__version__)
model = Sequential()
model.add(Dense(1, input_shape=(16,)))
fake_data = np.random.random((1, 16))
print(model.predict(fake_data).shape) # works
with tf.GradientTape() as tape:
print(model.predict(fake_data).shape) # LookupError: No gradient defined for operation 'IteratorGetNext' (op type: IteratorGetNext)
Run Code Online (Sandbox Code Playgroud)
这似乎在 TensorFlow 2.0.0 中有效,但在 TensorFlow 2.1.0 和 2.2.0 中失败
这是一个重现该问题的笔记本。
我使用草莓和草莓-django-plus构建了一个 GraphQL API ,该 API 使用 Django 托管在 http://localhost:8000/graphql 上。我能够在本地主机页面上使用 GraphiQL 成功与 API 交互。
\n我现在尝试使用GraphQL 代码生成器和 React 查询从前端访问 API。当我运行命令时yarn graphql-codegen,出现以下错误:
\xe2\x9c\x94 Parse configuration\n \xe2\x9d\xaf Generate outputs\n \xe2\x9d\xaf Generate src/generated/graphql.ts\n \xe2\x9c\x96 Load GraphQL schemas\n \xe2\x86\x92 Failed to load schema\n Load GraphQL documents\n Generate\n \xe2\x9d\xaf Generate ./graphql.schema.json\n \xe2\x9c\x96 Load GraphQL schemas\n \xe2\x86\x92 Failed to load schema\n Load GraphQL documents\n Generate\n\n\n Found 2 errors\n\n \xe2\x9c\x96 ./graphql.schema.json\n Failed to load schema from http://localhost:8000/graphql:\n\n Request with …Run Code Online (Sandbox Code Playgroud) django graphql graphql-codegen react-query strawberry-graphql