ValueError:输入“input_2”缺少数据。您传递了一个带有键 ['y', 'x'] 的数据字典。需要以下键:['input_2']
按照前面的代码此处 我正在评估联邦学习模型,但遇到了几个问题。 这是评估代码
central_test = test.create_tf_dataset_from_all_clients()
test_data = central_test.map(reshape_data)
# function that accepts a server state, and uses
#Keras to evaluate on the test dataset.
def evaluate(server_state):
keras_model = create_keras_model()
keras_model.compile(
loss=tf.keras.losses.SparseCategoricalCrossentropy(),
metrics=[tf.keras.metrics.SparseCategoricalAccuracy()]
)
keras_model.set_weights(server_state)
keras_model.evaluate(central_test)
server_state = federated_algorithm.initialize()
evaluate(server_state)
这是错误消息
ValueError: Missing data for input "input_2". You passed a data dictionary with keys ['y', 'x']. Expected the following keys: ['input_2']
那么这里会出现什么问题呢? create_tf_dataset_from_all_clients
方法的使用是否在正确的位置?因为-正如教程中所写的那样-用于创建一个集中式评估数据集。为什么我们需要使用集中式数据集?
Following the previous code here I am in process to evaluate the federated learning model and I got couple of issues.
This is the code for evaluation
central_test = test.create_tf_dataset_from_all_clients()
test_data = central_test.map(reshape_data)
# function that accepts a server state, and uses
#Keras to evaluate on the test dataset.
def evaluate(server_state):
keras_model = create_keras_model()
keras_model.compile(
loss=tf.keras.losses.SparseCategoricalCrossentropy(),
metrics=[tf.keras.metrics.SparseCategoricalAccuracy()]
)
keras_model.set_weights(server_state)
keras_model.evaluate(central_test)
server_state = federated_algorithm.initialize()
evaluate(server_state)
this is the error message
ValueError: Missing data for input "input_2". You passed a data dictionary with keys ['y', 'x']. Expected the following keys: ['input_2']
So what would be the problem here?
and is the use of the method create_tf_dataset_from_all_clients
in its right place? since -as it is written in the tutorial- used for create a centralized evaluation dataset. why do we need to use centralized dataset?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
test
数据集在评估期间具有不同的格式。尝试:The
test
dataset has a different format during evaluation. Try: