Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如果i';m使用keras方法,从firectory流出_Python_Machine Learning_Keras_Conv Neural Network - Fatal编程技术网

Python 如果i';m使用keras方法,从firectory流出

Python 如果i';m使用keras方法,从firectory流出,python,machine-learning,keras,conv-neural-network,Python,Machine Learning,Keras,Conv Neural Network,我想用平均值和标准偏差标准化我的数据,如下例所示: datagen.fit(数据) 平均值=数据元平均值 std=数据源std 打印(平均值,“平均值”) 打印(标准,“标准”) 在此之前,我将在预测文件中输入两个值(平均值和标准值)来调用此方法: def正常化(x,平均值,标准值): x[…,0]=平均值[0] x[…,1]=平均值[1] x[…,2]=平均值[2] x[…,0]/=std[0] x[…,1]/=std[1] x[…,2]/=std[2] 返回x 但在我的列车文件中,我使用

我想用平均值和标准偏差标准化我的数据,如下例所示:

datagen.fit(数据)
平均值=数据元平均值
std=数据源std
打印(平均值,“平均值”)
打印(标准,“标准”)
在此之前,我将在预测文件中输入两个值(平均值和标准值)来调用此方法:

def正常化(x,平均值,标准值):
x[…,0]=平均值[0]
x[…,1]=平均值[1]
x[…,2]=平均值[2]
x[…,0]/=std[0]
x[…,1]/=std[1]
x[…,2]/=std[2]
返回x
但在我的列车文件中,我使用了flow\u from\u目录的方法来获取数据:

train_datagen=ImageDataGenerator(
缩放范围=0.2,
重新缩放=1./255,
剪切范围=0.2,
水平翻转=真,
featurewise_center=True,
featurewise_std_normalization=True,)
列车生成器=来自列车目录(列车目录,
目标_大小=(224224),
批次尺寸=50,
class_mode='binary')
我的疑问是:如果我没有“x_train”数组,我怎么能传入
datagen.fit(data)

我做得对吗?

你可以自己计算平均值和std。之后,只需将这些值设置为数据生成器:

datagen = image.ImageDataGenerator(featurewise_center=True,
                               featurewise_std_normalization=True)
datagen.mean = np.array([111.1, 222.2, 333.3], dtype=np.float32).reshape((1,1,3))
datagen.std = np.array([5.3, 4.2, 6.3], dtype=np.float32).reshape((1,1,3))
你可以自己计算平均值和std。之后,只需将这些值设置为数据生成器:

datagen = image.ImageDataGenerator(featurewise_center=True,
                               featurewise_std_normalization=True)
datagen.mean = np.array([111.1, 222.2, 333.3], dtype=np.float32).reshape((1,1,3))
datagen.std = np.array([5.3, 4.2, 6.3], dtype=np.float32).reshape((1,1,3))

你是随机设置这些值的吗?什么是重塑?能回答我吗?你是随机设置这些值的吗?什么是重塑?能回答我吗?