小编use*_*948的帖子

GradientTape 中的简单 Keras 网络:LookupError:没有为操作“IteratorGetNext”定义梯度(操作类型:IteratorGetNext)

我构建了一个非常简单的带有单个密集层的 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 中失败

是一个重现该问题的笔记本。

python machine-learning keras tensorflow tensorflow2.0

11
推荐指数
1
解决办法
6095
查看次数

GraphQL 代码生成器 - 无法从 http://localhost:8000/graphql 加载架构 - 使用 GET/HEAD 方法的请求不能有正文

我使用草莓草莓-django-plus构建了一个 GraphQL API ,该 API 使用 Django 托管在 http://localhost:8000/graphql 上。我能够在本地主机页面上使用 GraphiQL 成功与 API 交互。

\n

我现在尝试使用GraphQL 代码生成器和 React 查询从前端访问 API。当我运行命令时yarn graphql-codegen,出现以下错误:

\n
\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

7
推荐指数
2
解决办法
1万
查看次数