python - SMOTE 技术不会过采样图像数据集
问题描述
我是 imblearn 库的新手。我的图像数据集属于 5 个类别,数据集高度不平衡。 我使用 tensorflow flow.from 目录函数加载图像并使用 smote 函数进行重采样。
img_height, img_width = 224,224
# the no. imgaes to load at each iteration
batch_size = 32
# only rescaling
train_datagen = ImageDataGenerator(
rescale=1./255,
zoom_range=0.2,
horizontal_flip=True,
vertical_flip=True
)
test_datagen = ImageDataGenerator(
rescale=1./255,
vertical_flip=True,
zoom_range=0.2,
horizontal_flip=True
)
# these are generators for train/test data that will read pictures #found in the defined subfolders of 'data/'
print('Total number of images for "training":')
train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size = (img_height, img_width),
batch_size = batch_size,
class_mode = "categorical",shuffle = True
#,color_mode='grayscale'
)
smote = SMOTE()
X_sm, y_sm = smote.fit_resample(train_generator, category_names)
单元开始运行,30 到 40 分钟后,jupyter 内核死了,我没有得到任何结果。请帮忙解决这个问题,我有 16 GB GPU,但 smote 没有在图像数据集上运行
解决方案
推荐阅读
- mysql - 尽可能快地获取我的 MySQL 的第一行(也在大表上)
- lua - 这个脚本有什么问题
- javascript - 仅在显示下拉菜单时显示叠加
- paypal - 如何构建“if”语句来测试用户是否已付款(贝宝商家工具)?
- python - 如何从同一应用的另一个用户那里获取用户应用的位置
- javascript - 使用各种键读取 Javascript 对象的值
- javascript - 如何为多个调试器设置 Visual Studio Code?
- laravel - 我在输入 migrate:fresh 时犯了一个错误,它有办法恢复已删除的数据吗
- zsh - 使用 powerlevel10k 时如何区分目录文本颜色?
- node.js - Node.js,如何从一些我必须在其中输入用户名和密码的 url 获取 JSON 元素?