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


Python scipy.inner函数代码示例

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


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

示例1: find_direction

    def find_direction(self, grad_diffs, steps, grad, hessian_diag, idxs):
        grad = grad.copy()  # We will change this.
        n_current_factors = len(idxs)

        # TODO: find a good name for this variable.
        rho = scipy.empty(n_current_factors)

        # TODO: vectorize this function
        for i in idxs:
            rho[i] = 1 / scipy.inner(grad_diffs[i], steps[i])

        # TODO: find a good name for this variable as well.
        alpha = scipy.empty(n_current_factors)

        for i in idxs[::-1]:
            alpha[i] = rho[i] * scipy.inner(steps[i], grad)
            grad -= alpha[i] * grad_diffs[i]
        z = hessian_diag * grad

        # TODO: find a good name for this variable (surprise!)
        beta = scipy.empty(n_current_factors)

        for i in idxs:
            beta[i] = rho[i] * scipy.inner(grad_diffs[i], z)
            z += steps[i] * (alpha[i] - beta[i])

        return z, {}
开发者ID:BRML,项目名称:climin,代码行数:27,代码来源:bfgs.py

示例2: corelationImage1Image2

 def corelationImage1Image2(imageArray1, imageArray2):
     image1 = scipy.inner(numpy.asarray(imageArray1), [299, 587, 114]) / 1000.0
     image2 = scipy.inner(numpy.asarray(imageArray2), [299, 587, 114]) / 1000.0
     
     image1 = (image1 - image1.mean())/ image1.std()
     image2 = (image2 - image2.mean())/ image2.std()
     
     corelationimage1Withimage2 = c2d(image1, image2, mode = 'same')
     return corelationimage1Withimage2.max()
开发者ID:arv100kri,项目名称:KB-AI-Project-3,代码行数:9,代码来源:Math.py

示例3: convert_to_grayscale

def convert_to_grayscale(img):
	shape = img.shape(img)
	if len(shape) == 1:
		return img
	elif len(shape) == 3:
		return sp.inner(img, [299, 587, 114]) / 1000
	elif len(shape) == 4:
		return sp.inner(img, [299, 587, 114, 0] / 1000)
	elif len(shape) == 2:
		return sp.inner(img, [1, 0])
	else:
		raise ValueError("The image has a non-standard bit-depth which is not supported.")
开发者ID:kurapan,项目名称:ImgHash,代码行数:12,代码来源:utils.py

示例4: get

def get(i):
    # get JPG image as Scipy array, RGB (3 layer)
    data = imread('/Users/kalaivanikubendran/Documents/Sideprojects/kalai-kaggle-code/train_sm/set175_%s.jpeg' % i)
    # convert to grey-scale using W3C luminance calc
    data = sp.inner(data, [299, 587, 114]) / 1000.0
    # normalize per http://en.wikipedia.org/wiki/Cross-correlation
    return (data - data.mean()) / data.std()
开发者ID:kramea,项目名称:kaggle_cv,代码行数:7,代码来源:scipy_test.py

示例5: grad_f1

    def grad_f1(self, a):
        "Define the gradient for each convex inequality."

        # Initialize the output vector
        out = sp.zeros((self.M, self.Na))

        # Preliminary calculation
        _xx = sp.einsum('mi,mj->mij', self.xarray, self.xarray)

        # Compute the four terms
        _Da = sp.tensordot(self.D, a, axes=[(0,), (0,)])
        _DDa = sp.tensordot(self.D, _Da, axes=[(1,), (0,)])
        xxDDa = sp.tensordot(_xx.reshape(self.M, self.ndim**2),
                             _DDa.reshape(self.Na, self.ndim**2),
                             axes=[(-1,), (-1,)])

        _BDa = sp.dot(self.B, _Da)
        xBDa = sp.inner(self.xarray, _BDa)

        _Ba = sp.dot(a, self.B)
        _DBa = sp.dot(_Ba, self.D)
        xDBa = sp.tensordot(self.xarray,
                            _DBa, axes=[(-1,), (-1,)])

        BBa = sp.dot(self.B, _Ba)
        
        # compute the gradient by summing the four terms
        out[:, :] = 2.0 * (xxDDa + xBDa + xDBa + BBa)

        return out
开发者ID:wgm2111,项目名称:wgm-optimization-sandbox,代码行数:30,代码来源:ellipsoidal_outlier_detector.py

示例6: norm

def norm(x):
    """2-norm of x
    """

    y = ravel(x)
    p = sqrt(inner(y, y))
    return p
开发者ID:dynaryu,项目名称:eqrm,代码行数:7,代码来源:numerical_tools.py

示例7: stateActionValue

 def stateActionValue(self, feature):
     r = self.tao(self.r) * self.r
     if self.enableOnlyEssentialFeatureInCritic:
         feature = self.module.decodeFeature(feature,
                                             self.essentialFeature)
     assert len(r) == self.criticdim, 'Wrong dimension of r'
     return scipy.inner(r, feature)
开发者ID:hbhzwj,项目名称:librl,代码行数:7,代码来源:td.py

示例8: get

def get(i):
   # get JPG image as Scipy array, RGB (3 layer)
  data = imread(i)
  # convert to grey-scale using W3C luminance calc
  data = sp.inner(data, [299, 587, 114]) / 1000.0
  # normalize per http://en.wikipedia.org/wiki/Cross-correlation
  return (data - data.mean()) / data.std()
开发者ID:ferdinandrosario,项目名称:puzzles,代码行数:7,代码来源:mirror.py

示例9: prepare_image_for_correlation

def prepare_image_for_correlation(im):
    letterArray = fromimage(im.convert('RGB'))
    # Black and white
    letterArray = scipy.inner(letterArray, [299, 587, 114]) / 1000.0
    # Normalize
    letterArray = (letterArray - letterArray.mean()) / letterArray.std()
    return letterArray
开发者ID:nachogoro,项目名称:wordcrack-herminia,代码行数:7,代码来源:boardgenerator.py

示例10: normalize

def normalize(x):
    n = scipy.sqrt(scipy.inner(x,x))
    #n = sl.norm(x, scipy.inf)
    if n > 0:
        return x/n
    else:
        return x
开发者ID:stevetjoa,项目名称:musicsearch,代码行数:7,代码来源:lsh.py

示例11: get_resized_data

def get_resized_data(origdata, size):
	'''Resize image data'''
	tmp = imresize(origdata, (size, size), interp="bilinear", mode=None)
	# convert to grey-scale using W3C luminance calc
	lum = [299, 587, 114]
	tmp = sp.inner(tmp, lum) / 1000.0
	# normalize per http://en.wikipedia.org/wiki/Cross-correlation
	return ((tmp - tmp.mean()) / tmp.std())
开发者ID:kissgyorgy,项目名称:real-estate-bot,代码行数:8,代码来源:deduplicator.py

示例12: f

 def f(self, x):
     self.net['mdrnn'].params[:] = x
     error = 0
     for (inpt, target) in self.trainds:
         output = self.net.activate(inpt)
         indic = output.reshape(self.width * self.height, 10).sum(axis=0)
         diff = indic - target
         error += scipy.inner(diff, diff)
     return error / len(self.trainds)
开发者ID:HKou,项目名称:pybrain,代码行数:9,代码来源:mnist.py

示例13: unsigned_volume

def unsigned_volume(pts):
    """Unsigned volume of a simplex    
    
    Computes the unsigned volume of an M-simplex embedded in N-dimensional 
    space. The points are stored row-wise in an array with shape (M+1,N).
    
    Parameters
    ----------
    pts : array
        Array with shape (M+1,N) containing the coordinates
        of the (M+1) vertices of the M-simplex.

    Returns
    -------
    volume : scalar
        Unsigned volume of the simplex

    Notes
    -----
    Zero-dimensional simplices (points) are assigned unit volumes.
        

    Examples
    --------
    >>> # 0-simplex point 
    >>> unsigned_volume( [[0,0]] )
    1.0
    >>> # 1-simplex line segment
    >>> unsigned_volume( [[0,0],[1,0]] )             
    1.0
    >>> # 2-simplex triangle 
    >>> unsigned_volume( [[0,0,0],[0,1,0],[1,0,0]] ) 
    0.5


    References
    ----------
    [1] http://www.math.niu.edu/~rusin/known-math/97/volumes.polyh

    """       
    
    pts = asarray(pts)
    
    M,N = pts.shape
    M -= 1

    if M < 0 or M > N:
        raise ValueError('array has invalid shape')
    
    if M == 0:
        return 1.0 
        
    A = pts[1:] - pts[0]
    return sqrt(det(inner(A,A)))/factorial(M)
开发者ID:DongliangGao,项目名称:pydec,代码行数:54,代码来源:volume.py

示例14: barycentric_gradients

def barycentric_gradients(pts):
    """
    Compute the gradients of the barycentric basis functions over a given simplex
    """            
    V = asarray(pts[1:] - pts[0])
    
    ##all gradients except the first are computed
    grads = dot(inv(inner(V,V)),V) #safer, but slower: grads = scipy.linalg.pinv2(V).T 
    
    ##since sum of all gradients is zero, simply compute the first from the others        
    return vstack((atleast_2d(-numpy.sum(grads,axis=0)),grads))
开发者ID:DongliangGao,项目名称:pydec,代码行数:11,代码来源:innerproduct.py

示例15: get

def get(pics,i):
    #global pics
    # get JPG image as Scipy array, RGB (3 layer)
    data = imread('%s%d.jpeg' %(pics,i))
    data = imresize(data,0.4)   
    #im2 = imresize(im22,0.5)
    #im3 = imresize(im33,0.5)
    # convert to grey-scale using W3C luminance calc
    data = sp.inner(data, [299, 587, 114]) / 1000.0
    # normalize as in http://en.wikipedia.org/wiki/Cross-correlation
    return (data - data.mean()) / data.std()
开发者ID:maninya,项目名称:navigation_system,代码行数:11,代码来源:img.py


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