当前位置: 首页>>代码示例>>Python>>正文


Python DenseDesignMatrix.apply方法代码示例

本文整理汇总了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
开发者ID:LeeEdel,项目名称:pylearn,代码行数:34,代码来源:test_preprocessing.py

示例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))
开发者ID:LeeEdel,项目名称:pylearn,代码行数:22,代码来源:test_preprocessing.py


注:本文中的pylearn2.datasets.dense_design_matrix.DenseDesignMatrix.apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。