Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

python 3.x - Image data shape changes during hyperparameter tuning

I have tried to create a siamese model based on some examples from this repo, combining some other samples from TensorFlow dataset API and Hparams parameter tuning, I have also tried to ensure the data that I give to the model follows the NHWC dimension ordering.

(32, 64, 64, 1) (32, 64, 64, 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)

When I run the parameter tuning, I can run one trial for a set of parameters without any problem, but when the second trial starts, I get a warning like the following

{'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, 64, 64, 1) for input KerasTensor(type_spec=TensorSpec(shape=(None, 64, 64, 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, 64, 1, 1).
WARNING:tensorflow:Model was constructed with shape (None, 64, 64, 1) for input KerasTensor(type_spec=TensorSpec(shape=(None, 64, 64, 1), dtype=tf.float32, name='input_2'), name='input_2', description="created by layer 'input_2'"), but it was called on an input with incompatible shape (64, 64, 1, 1).
WARNING:tensorflow:Model was constructed with shape (None, 64, 64, 1) for input KerasTensor(type_spec=TensorSpec(shape=(None, 64, 64, 1), dtype=tf.float32, name='conv_1_input'), name='conv_1_input', description="created by layer 'conv_1_input'"), but it was called on an input with incompatible shape (64, 64, 1, 1).

followed by an error

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, 1, 1], explicit_paddings=[], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](siamese_model/ExpandDims, siamese_model/sequential_5/conv_1/Conv2D/ReadVariableOp)' with input shapes: [64,64,1,1], [3,3,1,32].

This is the notebook in colab, I need some pointers on what is going on here because I have tried changing the input shapes to no use, looked at some related issues like this, but I have already checked the ordering of dimensions as suggested in the question

I have already run this example without the tuning part with 3 channel images, but couldn't get this to work.

This is another reference.

Thanks in advance for the help!

question from:https://stackoverflow.com/questions/65642550/image-data-shape-changes-during-hyperparameter-tuning

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...