0

R で fit_generator を使用するとエラーが発生します... これが私のコードです..`

model <- keras_model_sequential()

model %>%
  layer_conv_2d(32, c(3,3), input_shape = c(64, 64, 3)) %>%
  layer_activation("relu") %>%
  layer_max_pooling_2d(pool_size = c(2,2)) %>%
  layer_conv_2d(32, c(3, 3)) %>%
  layer_activation("relu") %>%
  layer_max_pooling_2d(pool_size = c(2, 2)) %>%
  layer_flatten() %>%
  layer_dense(128) %>%
  layer_activation("relu") %>%
  layer_dense(128) %>%
  layer_activation("relu") %>%
  layer_dense(2) %>%
  layer_activation("softmax")

opt <- optimizer_adam(lr = 0.001, decay = 1e-6)

model %>%
  compile(loss = "categorical_crossentropy", optimizer = opt, metrics = "accuracy")

train_gen <- image_data_generator(rescale = 1./255,
                                  shear_range = 0.2,
                                  zoom_range = 0.2,
                                  horizontal_flip = T)

test_gen <- image_data_generator(rescale = 1./255)

train_set = train_gen$flow_from_directory('dataset/training_set',
                                          target_size = c(64, 64),
                                          class_mode = "categorical")

test_set = test_gen$flow_from_directory('dataset/test_set',
                                        target_size = c(64, 64),
                                        batch_size = 32,
                                        class_mode = 'categorical')

model$fit_generator(train_set,
                    steps_per_epoch = 50,
                    epochs = 10)

エラー: py_call_impl(callable、dots$args、dots$keywords) のエラー: StopIteration: 'float' オブジェクトは整数として解釈できません

検証セットを入れると、bool(validation_data) という別のエラーが発生します。フロートエラー..

4

1 に答える 1