本文整理汇总了Python中pylearn2.datasets.dense_design_matrix.DenseDesignMatrix.apply方法的典型用法代码示例。如果您正苦于以下问题:Python DenseDesignMatrix.apply方法的具体用法?Python DenseDesignMatrix.apply怎么用?Python DenseDesignMatrix.apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylearn2.datasets.dense_design_matrix.DenseDesignMatrix
的用法示例。
在下文中一共展示了DenseDesignMatrix.apply方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unit_norm
# 需要导入模块: from pylearn2.datasets.dense_design_matrix import DenseDesignMatrix [as 别名]
# 或者: from pylearn2.datasets.dense_design_matrix.DenseDesignMatrix import apply [as 别名]
def test_unit_norm(self):
""" Test that using std_bias = 0.0 and use_norm = True
results in vectors having unit norm """
tol = 1e-5
num_examples = 5
num_features = 10
rng = np.random.RandomState([1,2,3])
X = as_floatX(rng.randn(5,10))
dataset = DenseDesignMatrix( X = X )
#the setting of subtract_mean is not relevant to the test
#the test only applies when std_bias = 0.0 and use_norm = True
preprocessor = GlobalContrastNormalization( subtract_mean = False,
std_bias = 0.0,
use_norm = True)
dataset.apply(preprocessor)
result = dataset.get_design_matrix()
norms = np.sqrt(np.square(result).sum(axis=1))
max_norm_error = np.abs(norms-1.).max()
tol = 3e-5
assert max_norm_error < tol
示例2: test_zero_vector
# 需要导入模块: from pylearn2.datasets.dense_design_matrix import DenseDesignMatrix [as 别名]
# 或者: from pylearn2.datasets.dense_design_matrix.DenseDesignMatrix import apply [as 别名]
def test_zero_vector(self):
""" Test that passing in the zero vector does not result in
a divide by 0 """
dataset = DenseDesignMatrix(X = as_floatX(np.zeros(())))
#the settings of subtract_mean and use_norm are not relevant to
#the test
#std_bias = 0.0 is the only value for which there should be a risk
#of failure occurring
preprocessor = GlobalContrastNormalization( subtract_mean = True,
std_bias = 0.0,
use_norm = False)
dataset.apply(preprocessor)
result = dataset.get_design_matrix()
assert not np.any(np.isnan(result))
assert not np.any(np.isinf(result))