1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

画像取り込み時、ValueError

Posted at

初投稿。
Kerasにて、画像分類を行う途中で発生した恥ずかしいエラーをメモ的に残す。

test.py
Using TensorFlow backend.
data/train/xxxxx/001.jpg
(3, 120, 120)
data/train/xxxxx/002.jpg
(3, 120, 120)
data/train/xxxxx/003.jpg
(4, 120, 120)
data/train/xxxxx/004.jpg
(3, 120, 120)
data/train/xxxxx/005.jpg
(3, 120, 120)
data/train/xxxxx/006.jpg
(3, 120, 120)
data/train/xxxxx/007.jpg
(3, 120, 120)
data/train/xxxxx/008.jpg
(3, 120, 120)
data/train/xxxxx/009.jpg
(3, 120, 120)
###################################
Traceback (most recent call last):
  File "test.py", line 74, in <module>
    history = model.fit(images_list, Y, epochs=5, batch_size=10, validation_split=0.1)
  File "/usr/lib64/python3.6/site-packages/keras/models.py", line 870, in fit
    initial_epoch=initial_epoch)
  File "/usr/lib64/python3.6/site-packages/keras/engine/training.py", line 1435, in fit
    batch_size=batch_size)
  File "/usr/lib64/python3.6/site-packages/keras/engine/training.py", line 1311, in _standardize_user_data
    exception_prefix='input')
  File "/usr/lib64/python3.6/site-packages/keras/engine/training.py", line 127, in _standardize_input_data
    str(array.shape))
ValueError: Error when checking input: expected conv2d_1_input to have 4 dimensions, but got array with shape (36, 1)

RGBの3次元を扱う想定が、4次元になっているのがいた模様。
そういえば、png→jpgにした画像あったなと、恥ずか悲しいエラー。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?