超参数调整期间图像数据形状的变化

问题描述

我已尝试基于此 repo 中的一些示例创建一个连体模型,并结合来自 TensorFlow dataset APIHparams parameter tuning 的一些其他示例,我还尝试确保我的数据给模型遵循 NHWC 维度排序。

(32,64,1) (32,1) tf.Tensor(
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 0. 0. 1. 1. 1. 1. 1. 1. 0. 1. 1. 1. 1.
 1. 1. 0. 1. 1. 1. 1. 1.],shape=(32,),dtype=float32)

当我运行参数调整时,我可以为一组参数运行一次试验没有任何问题,但是当第二次试验开始时,我收到如下警告

{'num_units': 16,'dropout': 0.1,'optimizer': 'adam'}
Epoch 1/5
16/16 [==============================] - 5s 267ms/step - loss: nan - accuracy: 0.2704

Epoch 00001: saving model to /content/ckpt-dir/ckpt-0001.ckpt
Epoch 2/5
16/16 [==============================] - 4s 263ms/step - loss: nan - accuracy: 0.1358

Epoch 00002: saving model to /content/ckpt-dir/ckpt-0002.ckpt
Epoch 3/5
16/16 [==============================] - 4s 263ms/step - loss: nan - accuracy: 0.1421

Epoch 00003: saving model to /content/ckpt-dir/ckpt-0003.ckpt
Epoch 4/5
16/16 [==============================] - 4s 263ms/step - loss: nan - accuracy: 0.1455

Epoch 00004: saving model to /content/ckpt-dir/ckpt-0004.ckpt
Epoch 5/5
16/16 [==============================] - 4s 263ms/step - loss: nan - accuracy: 0.1424

Epoch 00005: saving model to /content/ckpt-dir/ckpt-0005.ckpt
WARNING:tensorflow:Model was constructed with shape (None,1) for input KerasTensor(type_spec=TensorSpec(shape=(None,1),dtype=tf.float32,name='input_1'),name='input_1',description="created by layer 'input_1'"),but it was called on an input with incompatible shape (64,1,1).
WARNING:tensorflow:Model was constructed with shape (None,name='input_2'),name='input_2',description="created by layer 'input_2'"),name='conv_1_input'),name='conv_1_input',description="created by layer 'conv_1_input'"),1).

出现错误

ValueError: Negative dimension size caused by subtracting 3 from 1 for '{{node siamese_model/sequential_5/conv_1/Conv2D}} = Conv2D[T=DT_FLOAT,data_format="NHWC",dilations=[1,1],explicit_paddings=[],padding="VALID",strides=[1,use_cudnn_on_gpu=true](siamese_model/ExpandDims,siamese_model/sequential_5/conv_1/Conv2D/ReadVariableOp)' with input shapes: [64,[3,3,32].

这是 colab 中的笔记本,我需要一些关于这里发生的事情的指示,因为我尝试将输入形状更改为无用,查看了一些相关问题,例如 this,但我已经按照 question

中的建议检查了尺寸的顺序

我已经用 3 通道图像在没有调整部分的情况下运行了这个例子,但无法让它工作。

This 是另一个参考。

预先感谢您的帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)