0

画像診断のプログラムを組みたいのですが、下記のようなエラーが出てしまいます。
Jupyer Notebookを使用しており、kaggleのChest X-Ray Images (Pneumonia)というデータセットから何枚かダウンロードして使おうとしています。

解決方法を教えていただければ幸いです。

こちらがテストデータの一つです。
胸部のX線画像

こちらの動画を参考にしました。
Pythonによるディープラーニングの作り方〜画像認識〜【Python機械学習入門#10】

ソースコード

import numpy as np
import tensorflow as tf
import glob


X_train = []
y_train = []
X_test = []
y_test = []

img_data=tf.io.read_file("image/train/0_normal/IM-0133-0001.jpeg")

for f in glob.glob("/image/*/*/*.jpeg"):
    img_data = tf.io.read_file(f)
    img_data = tf.io.decode_jpeg(img_data)
    img_data = tf.image.resize(img_data,[100,100])
  
    if f.split("/")[1]=="train":
        X_train.append(img_data)
        y_train.append(int(f.split("/")[2].split("_")[0]))
    elif f.split("/")[1]=="test":
          X_test.append(img_data)
          y_test.append(int(f.split("/")[2].split("_")[0]))


X_train = np.array(X_train) / 255.0
y_train = np.array(y_train)
X_test = np.array(X_test) / 255.0
y_test = np.array(y_test)
model=tf.keras.models.Sequential([
    tf.keras.layers.Flatten(input_shape=(100,100,3)),
    tf.keras.layers.Dense(64,activation="relu"),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(2,activation="softmax")
])
model.compile(optimizer="adam",loss="sparse_categorical_crossentropy",metrics=["accuracy"])

model.fit(X_train, y_train, epochs=10)

エラーメッセージ

Epoch 1/10
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17544/1266188578.py in <module>
      1 model.compile(optimizer="adam",loss="sparse_categorical_crossentropy",metrics=["accuracy"])
      2 
----> 3 model.fit(X_train, y_train, epochs=10)

~\anaconda3\envs\tensorflow16\lib\site-packages\keras\utils\traceback_utils.py in error_handler(*args, **kwargs)
     65     except Exception as e:  # pylint: disable=broad-except
     66       filtered_tb = _process_traceback_frames(e.__traceback__)
---> 67       raise e.with_traceback(filtered_tb) from None
     68     finally:
     69       del filtered_tb

~\anaconda3\envs\tensorflow16\lib\site-packages\keras\engine\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
   1393         logs = tf_utils.sync_to_numpy_or_python_type(logs)
   1394         if logs is None:
-> 1395           raise ValueError('Unexpected result of `train_function` '
   1396                            '(Empty logs). Please use '
   1397                            '`Model.compile(..., run_eagerly=True)`, or '

ValueError: Unexpected result of `train_function` (Empty logs). Please use `Model.compile(..., run_eagerly=True)`, or `tf.config.run_functions_eagerly(True)` for more information of where went wrong, or file a issue/bug to `tf.keras`.
1

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。