• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sort.sort函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中theano.tensor.sort.sort函数的典型用法代码示例。如果您正苦于以下问题:Python sort函数的具体用法?Python sort怎么用?Python sort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sort函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_grad_negative_axis_3d

 def test_grad_negative_axis_3d(self):
     data = np.random.rand(2, 3, 4).astype(theano.config.floatX)
     utt.verify_grad(lambda x: sort(x, -1), [data])
     data = np.random.rand(2, 3, 4).astype(theano.config.floatX)
     utt.verify_grad(lambda x: sort(x, -2), [data])
     data = np.random.rand(2, 3, 4).astype(theano.config.floatX)
     utt.verify_grad(lambda x: sort(x, -3), [data])
开发者ID:12190143,项目名称:Theano,代码行数:7,代码来源:test_sort.py


示例2: test_grad_none_axis

    def test_grad_none_axis(self):
        data = np.random.rand(10).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, None), [data])
        utt.verify_grad(lambda x: sort(x, 0), [data])

        data = np.random.rand(2, 3).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, None), [data])
开发者ID:Jackwangyang,项目名称:Theano,代码行数:7,代码来源:test_sort.py


示例3: test_grad_nonnegative_axis_4d

 def test_grad_nonnegative_axis_4d(self):
     data = np.random.rand(2, 3, 4, 2).astype(theano.config.floatX)
     utt.verify_grad(lambda x: sort(x, 0), [data])
     data = np.random.rand(2, 3, 4, 2).astype(theano.config.floatX)
     utt.verify_grad(lambda x: sort(x, 1), [data])
     data = np.random.rand(2, 3, 4, 2).astype(theano.config.floatX)
     utt.verify_grad(lambda x: sort(x, 2), [data])
     data = np.random.rand(2, 3, 4, 2).astype(theano.config.floatX)
     utt.verify_grad(lambda x: sort(x, 3), [data])
开发者ID:12190143,项目名称:Theano,代码行数:9,代码来源:test_sort.py


示例4: test_sort

 def test_sort(self):
     x = tensor.matrix()
     self._compile_and_check(
             [x],
             [sort(x)],
             [np.random.randn(10, 40).astype(theano.config.floatX)],
             SortOp)
     self._compile_and_check(
             [x],
             [sort(x, axis=None)],
             [np.random.randn(10, 40).astype(theano.config.floatX)],
             SortOp)
开发者ID:12190143,项目名称:Theano,代码行数:12,代码来源:test_sort.py


示例5: test_None

 def test_None(self):
     a = tensor.dmatrix()
     l = sort(a, None)
     f = theano.function([a], l)
     gv = f(self.m_val)
     gt = np.sort(self.m_val, None)
     assert np.allclose(gv, gt)
开发者ID:12190143,项目名称:Theano,代码行数:7,代码来源:test_sort.py


示例6: test3

 def test3(self):
     a = tensor.dvector()
     w2 = sort(a)
     f = theano.function([a], w2)
     gv = f(self.v_val)
     gt = np.sort(self.v_val)
     assert np.allclose(gv, gt)
开发者ID:12190143,项目名称:Theano,代码行数:7,代码来源:test_sort.py


示例7: test4

 def test4(self):
     a = tensor.dmatrix()
     axis = tensor.scalar()
     l = sort(a, axis, "mergesort")
     f = theano.function([a, axis], l)
     for axis_val in 0, 1:
         gv = f(self.m_val, axis_val)
         gt = np.sort(self.m_val, axis_val)
         assert np.allclose(gv, gt)
开发者ID:12190143,项目名称:Theano,代码行数:9,代码来源:test_sort.py


示例8: test2

 def test2(self):
     a = tensor.dmatrix()
     axis = tensor.scalar()
     w = sort(a, axis)
     f = theano.function([a, axis], w)
     for axis_val in 0, 1:
         gv = f(self.m_val, axis_val)
         gt = np.sort(self.m_val, axis_val)
         utt.assert_allclose(gv, gt)
开发者ID:Theano,项目名称:Theano,代码行数:9,代码来源:test_sort.py


示例9: test_grad_negative_axis

    def test_grad_negative_axis(self):
        # test 2D
        data = np.random.rand(2, 3).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -1), [data])
        data = np.random.rand(2, 3).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -2), [data])

        # test 3D
        data = np.random.rand(2, 3, 4).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -1), [data])
        data = np.random.rand(2, 3, 4).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -2), [data])
        data = np.random.rand(2, 3, 4).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -3), [data])

        # test 4D
        data = np.random.rand(2, 3, 4, 2).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -1), [data])
        data = np.random.rand(2, 3, 4, 2).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -2), [data])
        data = np.random.rand(2, 3, 4, 2).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -3), [data])
        data = np.random.rand(2, 3, 4, 2).astype(theano.config.floatX)
        utt.verify_grad(lambda x: sort(x, -4), [data])
开发者ID:Abioy,项目名称:Theano,代码行数:24,代码来源:test_sort.py


示例10: test1

 def test1(self):
     a = tensor.dmatrix()
     w = sort(a)
     f = theano.function([a], w)
     assert np.allclose(f(self.m_val), np.sort(self.m_val))
开发者ID:12190143,项目名称:Theano,代码行数:5,代码来源:test_sort.py


示例11: sort

 def sort(self, axis=-1, kind='quicksort', order=None):
     """See `theano.tensor.sort`"""
     from theano.tensor.sort import sort
     return sort(self, axis, kind, order)
开发者ID:Donghuan,项目名称:Theano,代码行数:4,代码来源:var.py


示例12: __init__

    def __init__(self, width, height, potentialInhibWidth, potentialInhibHeight,
                 desiredLocalActivity, minOverlap, centerInhib=1):
        # Temporal Parameters
        ###########################################
        # Specifies if the potential synapses are centered
        # over the columns
        self.centerInhib = centerInhib
        self.width = width
        self.height = height
        self.potentialWidth = potentialInhibWidth
        self.potentialHeight = potentialInhibHeight
        self.areaKernel = self.potentialWidth * self.potentialHeight
        self.desiredLocalActivity = desiredLocalActivity
        self.minOverlap = minOverlap
        # Store how much padding is added to the input grid
        self.topPos_y = 0
        self.bottomPos_y = 0
        self.leftPos_x = 0
        self.rightPos_x = 0

        # Create theano variables and functions
        ############################################
        # Create the theano function for calculating
        # if the colInConvole matrix. This takes a vector
        # storing an offset number and adds this to the input
        # matrix if the element in the input matrix is greater then
        # zero.
        self.in_colPatMat = T.matrix(dtype='int32')
        self.in_colAddVect = T.vector(dtype='int32')
        self.in_colNegVect = T.vector(dtype='int32')
        self.col_num3 = T.matrix(dtype='int32')
        self.check_gtZero2 = T.switch(T.gt(self.in_colPatMat, 0),
                                     (self.in_colPatMat +
                                      self.in_colAddVect[self.col_num3] -
                                      self.in_colNegVect[self.col_num3]+1),
                                      0)
        self.add_toConvolePat = function([self.in_colPatMat,
                                          self.in_colAddVect,
                                          self.in_colNegVect,
                                          self.col_num3],
                                         self.check_gtZero2,
                                         allow_input_downcast=True)

        # Create the theano function for calculating
        # the addition of a small tie breaker value to each overlap value.
        self.o_grid = T.matrix(dtype='float32')
        self.tie_grid = T.matrix(dtype='float32')
        self.add_vals = T.add(self.o_grid, self.tie_grid)
        self.add_tieBreaker = function([self.o_grid, self.tie_grid],
                                       self.add_vals,
                                       on_unused_input='warn',
                                       allow_input_downcast=True)

        # Create the theano function for calculating
        # the inputs to a column from an input grid.
        self.kernalSize = (self.potentialHeight, self.potentialWidth)
        # poolstep is how far to move the kernal in each direction.
        self.poolstep = (1, 1)
        # Create the theano function for calculating the overlaps of
        # the potential columns that any column can inhibit.
        self.neib_shape = T.as_tensor_variable(self.kernalSize)
        self.neib_step = T.as_tensor_variable(self.poolstep)
        self.pool_inp = T.tensor4('pool_input', dtype='float32')
        self.pool_convole = images2neibs(self.pool_inp, self.neib_shape, self.neib_step, mode='valid')
        self.pool_inputs = function([self.pool_inp],
                                    self.pool_convole,
                                    on_unused_input='warn',
                                    allow_input_downcast=True)

        # Create the theano function for calculating
        # the sorted vector of overlaps for each columns inhib overlaps
        self.o_mat = tensor.dmatrix()
        #self.so_mat = tensor.dmatrix()
        self.axis = tensor.scalar()
        self.arg_sort = sort(self.o_mat, self.axis, "quicksort")
        self.sort_vect = function([self.o_mat, self.axis], self.arg_sort)

        # Create the theano function for calculating
        # the minOverlap from the sorted vector of overlaps for each column.
        # This function takes a vector of indicies indicating where the
        # minLocalActivity resides for each row in the matrix.
        # Note: the sorted overlap matrix goes from low to highest so use neg index.
        self.min_OIndex = T.vector(dtype='int32')
        self.s_ColOMat = T.matrix(dtype='float32')
        self.row_numVect2 = T.vector(dtype='int32')
        self.get_indPosVal = self.s_ColOMat[self.row_numVect2, -self.min_OIndex]
        self.get_minLocAct = function([self.min_OIndex,
                                       self.s_ColOMat,
                                       self.row_numVect2],
                                      self.get_indPosVal,
                                      allow_input_downcast=True
                                      )

        # Create the theano function for calculating
        # if a column should be active or not based on whether it
        # has an overlap greater then or equal to the minLocalActivity.
        self.minLocalActivity = T.matrix(dtype='float32')
        self.colOMat = T.matrix(dtype='float32')
        self.check_gt_zero = T.switch(T.gt(self.colOMat, 0), 1, 0)
        self.check_gteq_minLocAct = T.switch(T.ge(self.colOMat, self.minLocalActivity), self.check_gt_zero, 0)
#.........这里部分代码省略.........
开发者ID:calumroy,项目名称:HTM,代码行数:101,代码来源:theano_inhibition.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python disturb_mem.disturb_mem函数代码示例发布时间:2022-05-27
下一篇:
Python slinalg.cholesky函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap