我正在尝试使用R中的Keras创建模型:
img_width <- 6
img_height <- 6
files <- list.files(path="./data2", pattern=".JPG",all.files=T, full.names=T)
list_of_images = lapply(files, load.image)
list_of_images_resized <- lapply(list_of_images, resize, size_x = img_width, size_y = img_height )
data <- list_of_images_resized
model <- keras_model_sequential()
# add layers and compile the model
model %>%
layer_dense(units = 2, activation = 'relu', input_shape=c(img_height, img_width, 3)) %>%
layer_dense(units = 1, activation = 'sigmoid') %>%
compile(
optimizer = 'rmsprop',
loss = 'binary_crossentropy',
metrics = c('accuracy')
)
model %>% fit(data, labels, epochs=3, batch_size=4)
然而,拟合给出以下错误:
Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 arrays but instead got the following list of 32 arrays: [array([[[[ 1. , 1. , 1. ]], [[ 1. , 1. , 1. ]], [[ 1. , 1. , 1. ]], [[ 1. , 1. , 1. ...
请告知