如何解决InvalidArgumentError with model.fit in Tensorflow
使用 CNN 进行图像分类。当调用 model.fit()
时,它开始训练模型一段时间,在执行过程中被中断并返回错误消息。
错误信息如下
InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: Input size should match (header_size + row_size * abs_height) but they differ by 2
[[{{node decode_image/DecodeImage}}]]
[[IteratorGetNext]]
[[IteratorGetNext/_4]]
(1) Invalid argument: Input size should match (header_size + row_size * abs_height) but they differ by 2
[[{{node decode_image/DecodeImage}}]]
[[IteratorGetNext]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_8873]
Function call stack:
train_function -> train_function
更新:我的建议是检查数据集的元数据。它帮助解决了我的问题。
解决方法
您没有指定参数 $ swagger-cli validate main.yaml
。为了使用 @app.route("/app_main_page/preke/<int:p_id>",methods=["GET","POST"])
@login_required
def viena_preke(p_id):
form = UpdateItemForm()
preke = Preke.query.get(p_id)
if form.validate_on_submit():
if form.prekes_nuotrauka.data:
file = save_pict(form.prekes_nuotrauka.data)
preke.pavadinimas = form.pavadinimas.data
preke.apibudinimas = form.apibudinimas.data
preke.author = current_user
db.session.commit()
flash("Jusu preke buvo atnaujinta","success")
return redirect(url_for("visos_prekes"))
else:
form.pavadinimas.data = preke.pavadinimas
form.apibudinimas.data = preke.apibudinimas
return render_template("VienaPreke.html",title="Viena preke",preke=preke,form=form,image = file)
作为损失函数,您需要将其设置为 label_mode
。
如果您不指定它,则将其设置为 SparseCategoricalCrossentropy
为 per the documentation。
您还需要根据您从中读取图像的目录结构将参数 int
指定为 None
。
labels
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。