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。 如果您不指定它,则将其设置为 SparseCategoricalCrossentropyper the documentation

您还需要根据您从中读取图像的目录结构将参数 int 指定为 None

labels

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...