首页 > 解决方案 > 我正在 juypter 上的 python 中使用 Keras 包

问题描述

这是我尝试执行以重新缩放矩阵的代码,或者我们可以说训练示例:

scaler=MinMaxScaler(feature_range=(0,1))
scaled_trained_samples=scaler.fit_transform((train_samples).train_reshape(-1,+1))

错误是:

AttributeError                            Traceback (most recent call last)
<ipython-input-18-983807c433d9> in <module>
      1 scaler=MinMaxScaler(feature_range=(0,1))
----> 2 scaled_trained_samples=scaler.fit_transform((train_samples).train_reshape(-1,+1))

AttributeError: 'numpy.ndarray' object has no attribute 'train_reshape'

标签: pythonkeras

解决方案


它接缝train_samples是一个 numpy 数组。train_reshape是缩放器的一种方法。例如,您可以这样做scaler.train_reshape(),但不能train_samples.train_reshape()

为此,请尝试:

scaled_trained_samples=scaler.fit_transform(train_samples.reshape(-1,+1))

推荐阅读