如何导入模块应用转换或替换为其他?

2024-06-20 12:01:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法导入“应用变换”和“变换矩阵”“偏移中心”。 我尝试使用ImageDataGenerator但我也遇到了问题!在

from keras.preprocessing.image import apply_transform, transform_matrix_offset_center

ImportError: cannot import name 'apply_transform'


Tags: fromimageimporttransform矩阵中心matrixkeras
1条回答
网友
1楼 · 发布于 2024-06-20 12:01:41

这取决于你运行的是哪个版本的keras。根据这个Github-issue,关于文档有一点混乱。当涉及到apply_transform时,post解决了最新版本的问题。在我的Keras版本(2.1.5)from keras.preprocessing.image import apply_transform起作用,但是在后面的版本中,正如前面提到的apply_transform被移到{}。在

至于transform_matrix_offset_center,根据keras.preprocessing.image的源代码,line 21中很明显,from keras.preprocessing.image import transform_matrix_offset_center应该可以工作。您可以参考releases-timeline来了解每个版本中的不同更改

相关问题 更多 >