Questions tagged «data-science»

7
我在哪里可以在Keras中调用BatchNormalization函数?
如果我想在Keras中使用BatchNormalization函数,那么是否仅需要在开始时调用一次? 我为此阅读了该文档:http : //keras.io/layers/normalization/ 我看不到该怎么称呼它。下面是我尝试使用它的代码: model = Sequential() keras.layers.normalization.BatchNormalization(epsilon=1e-06, mode=0, momentum=0.9, weights=None) model.add(Dense(64, input_dim=14, init='uniform')) model.add(Activation('tanh')) model.add(Dropout(0.5)) model.add(Dense(64, init='uniform')) model.add(Activation('tanh')) model.add(Dropout(0.5)) model.add(Dense(2, init='uniform')) model.add(Activation('softmax')) sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True) model.compile(loss='binary_crossentropy', optimizer=sgd) model.fit(X_train, y_train, nb_epoch=20, batch_size=16, show_accuracy=True, validation_split=0.2, verbose = 2) 我问,因为如果我用第二行(包括批处理规范化)运行代码,而如果我不使用第二行运行代码,则会得到类似的输出。因此,要么我没有在正确的位置调用该函数,要么我猜它并没有太大的区别。

13
无法将“ Conda”识别为内部或外部命令
我在Windows 7 Professional计算机上安装了Anaconda3 4.4.0(32位),并在Jupyter笔记本电脑上导入了NumPy和Pandas,因此我认为Python已正确安装。但是当我键入conda list并conda --version在命令提示符下时,它说conda is not recognized as internal or external command. 我已经为Anaconda3设置了环境变量;Variable Name: Path,Variable Value: C:\Users\dipanwita.neogy\Anaconda3 我该如何运作?

6
无法分配具有形状和数据类型的数组
我在Ubuntu 18上在numpy中分配大型数组时遇到了一个问题,而在MacOS上却没有遇到同样的问题。 我想一个numpy的阵列形状分配内存(156816, 36, 53806) 使用 np.zeros((156816, 36, 53806), dtype='uint8') 当我在Ubuntu OS上遇到错误时 >>> import numpy as np >>> np.zeros((156816, 36, 53806), dtype='uint8') Traceback (most recent call last): File "<stdin>", line 1, in <module> numpy.core._exceptions.MemoryError: Unable to allocate array with shape (156816, 36, 53806) and data type uint8 我没有在MacOS上得到它: >>> import …

5
如何在Keras中从HDF5文件加载模型?
如何在Keras中从HDF5文件加载模型? 我试过的 model = Sequential() model.add(Dense(64, input_dim=14, init='uniform')) model.add(LeakyReLU(alpha=0.3)) model.add(BatchNormalization(epsilon=1e-06, mode=0, momentum=0.9, weights=None)) model.add(Dropout(0.5)) model.add(Dense(64, init='uniform')) model.add(LeakyReLU(alpha=0.3)) model.add(BatchNormalization(epsilon=1e-06, mode=0, momentum=0.9, weights=None)) model.add(Dropout(0.5)) model.add(Dense(2, init='uniform')) model.add(Activation('softmax')) sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True) model.compile(loss='binary_crossentropy', optimizer=sgd) checkpointer = ModelCheckpoint(filepath="/weights.hdf5", verbose=1, save_best_only=True) model.fit(X_train, y_train, nb_epoch=20, batch_size=16, show_accuracy=True, validation_split=0.2, verbose = 2, callbacks=[checkpointer]) 上面的代码成功将最佳模​​型保存到名为weights.hdf5的文件中。然后,我要加载该模型。以下代码显示了我如何尝试这样做: model2 …

13
fit_transform()接受2个位置参数,但LabelBinarizer给出了3个
我是机器学习的新手,并且一直在研究无监督学习技术。 该图显示了我的示例数据(所有清洁后)屏幕截图: 示例数据 我有两个用来清理数据的Pipline: num_attribs = list(housing_num) cat_attribs = ["ocean_proximity"] print(type(num_attribs)) num_pipeline = Pipeline([ ('selector', DataFrameSelector(num_attribs)), ('imputer', Imputer(strategy="median")), ('attribs_adder', CombinedAttributesAdder()), ('std_scaler', StandardScaler()), ]) cat_pipeline = Pipeline([ ('selector', DataFrameSelector(cat_attribs)), ('label_binarizer', LabelBinarizer()) ]) 然后,我将这两个管道进行了合并,相同的代码如下所示: from sklearn.pipeline import FeatureUnion full_pipeline = FeatureUnion(transformer_list=[ ("num_pipeline", num_pipeline), ("cat_pipeline", cat_pipeline), ]) 现在,我正在尝试对数据执行fit_transform,但它向我显示了错误。 转换代码: housing_prepared = full_pipeline.fit_transform(housing) housing_prepared …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.