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

Python scalar.get_scalar_type函数代码示例

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

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



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

示例1: _get_func

    def _get_func(self):
        from theano.scalar import get_scalar_type

        if self._fn is None:
            v = get_scalar_type('int64')()
            self._fn = theano.function([v], _make_cdata(self)(v), profile=False)
        return self._fn
开发者ID:intel,项目名称:theano,代码行数:7,代码来源:type.py


示例2: safe_new

def safe_new(x, tag='', dtype=None):
    """
    Internal function that constructs a new variable from x with the same
    type, but with a different name (old name + tag). This function is used
    by gradient, or the R-op to construct new variables for the inputs of
    the inner graph such that there is no interference between the original
    graph and the newly constructed graph.
    """
    if hasattr(x, 'name') and x.name is not None:
        nw_name = x.name + tag
    else:
        nw_name = None

    if isinstance(x, theano.Constant):
        if dtype and x.dtype != dtype:
            casted_x = x.astype(dtype)
            nwx = x.__class__(casted_x.type, x.data, x.name)
            nwx.tag = copy(x.tag)
            return nwx
        else:
            return x.clone()
    # Note, as_tensor_variable will convert the Scalar into a
    # TensorScalar that will require a ScalarFromTensor op,
    # making the pushout optimization fail
    elif isinstance(x, scalar.ScalarVariable):
        if dtype:
            nw_x = scalar.get_scalar_type(dtype=dtype)()
        else:
            nw_x = x.type()
        nw_x.name = nw_name
        return nw_x
    else:
        try:
            x = tensor.as_tensor_variable(x)
        except TypeError:
            # This could happen for example for random states, and I really
            # want to avoid the convoluted logic that checks for cuda
            # ndarrays
            pass
    nw_x = x.type()
    if dtype and nw_x.dtype != dtype:
        nw_x = nw_x.astype(dtype).type()
    nw_x.name = nw_name

    # Preserve test values so that the 'compute_test_value' option can be used.
    # The test value is deep-copied to ensure there can be no interactions
    # between test values, due to inplace operations for instance. This may
    # not be the most efficient memory-wise, though.
    if theano.config.compute_test_value != 'off':
        try:
            nw_x.tag.test_value = copy.deepcopy(gof.op.get_test_value(x))
        except AttributeError:
            # This means `x` has no test value.
            pass

    return nw_x
开发者ID:Jackwangyang,项目名称:Theano,代码行数:56,代码来源:scan_utils.py


示例3: __new__

 def __new__(self, *types):
     """
     Upgrade any int types to float32 or float64 to avoid losing precision.
     """
     conv = {scalar.int8: scalar.float32,
             scalar.int16: scalar.float32,
             scalar.int32: scalar.float64,
             scalar.int64: scalar.float64,
             scalar.uint8: scalar.float32,
             scalar.uint16: scalar.float32,
             scalar.uint32: scalar.float64,
             scalar.uint64: scalar.float64}
     return [scalar.get_scalar_type(scalar.Scalar.upcast(conv.get(t, t))) for t in types]
开发者ID:surban,项目名称:TheanoOpTest,代码行数:13,代码来源:optest.py


示例4: _get_func

    def _get_func(self):
        """
        Return a function that makes a value from an integer.

        The integer value is assumed to be a valid pointer for the
        type and no check is done to ensure that.
        """
        from theano.scalar import get_scalar_type

        if self._fn is None:
            with change_flags(compute_test_value='off'):
                v = get_scalar_type('int64')()
                self._fn = theano.function([v], _make_cdata(self)(v),
                                           profile=False)
        return self._fn
开发者ID:ChinaQuants,项目名称:Theano,代码行数:15,代码来源:type.py


示例5: c_code_cache_version

 def c_code_cache_version(self):
     scalar_version = scal.get_scalar_type(self.dtype).c_code_cache_version()
     if scalar_version:
         return (11,) + scalar_version
     else:
         return ()
开发者ID:alimuldal,项目名称:Theano,代码行数:6,代码来源:type.py


示例6: c_init_code

 def c_init_code(self):
     return scal.get_scalar_type(self.dtype).c_init_code()
开发者ID:alimuldal,项目名称:Theano,代码行数:2,代码来源:type.py


示例7: c_support_code

 def c_support_code(self):
     """Override `CLinkerObject.c_support_code` """
     return scal.get_scalar_type(self.dtype).c_support_code()
开发者ID:alimuldal,项目名称:Theano,代码行数:3,代码来源:type.py


示例8: c_compile_args

 def c_compile_args(self):
     return scal.get_scalar_type(self.dtype).c_compile_args()
开发者ID:alimuldal,项目名称:Theano,代码行数:2,代码来源:type.py


示例9: c_libraries

 def c_libraries(self):
     return scal.get_scalar_type(self.dtype).c_libraries()
开发者ID:alimuldal,项目名称:Theano,代码行数:2,代码来源:type.py


示例10: c_headers

 def c_headers(self):
     """Override `CLinkerObject.c_headers` """
     return scal.get_scalar_type(self.dtype).c_headers()
开发者ID:alimuldal,项目名称:Theano,代码行数:3,代码来源:type.py


示例11: to_scalar_type

 def to_scalar_type(self):
     return scal.get_scalar_type(dtype=self.dtype)
开发者ID:alimuldal,项目名称:Theano,代码行数:2,代码来源:type.py


示例12: get_scalar_type

# Code:

from __future__ import print_function

import numpy
import theano
from theano import scalar as scal
from theano import printing
from theano.printing import pprint
from theano.scalar import get_scalar_type, neg, sqr
from theano.tensor import elemwise

# ------------------------------------------------------------------------
# Types
int8 = get_scalar_type('int8')
int16 = get_scalar_type('int16')
int32 = get_scalar_type('int32')
int64 = get_scalar_type('int64')
uint8 = get_scalar_type('uint8')
uint16 = get_scalar_type('uint16')
uint32 = get_scalar_type('uint32')
uint64 = get_scalar_type('uint64')
float32 = get_scalar_type('float32')
float64 = get_scalar_type('float64')
complex64 = get_scalar_type('complex64')
complex128 = get_scalar_type('complex128')

int_types = int8, int16, int32, int64
uint_types = uint8, uint16, uint32, uint64
float_types = float32, float64
开发者ID:caomw,项目名称:learn-orientation,代码行数:30,代码来源:custom_theano.py


示例13: c_libraries

 def c_libraries(self, c_compiler):
     return scal.get_scalar_type(self.dtype).c_libraries(c_compiler)
开发者ID:ChinaQuants,项目名称:Theano,代码行数:2,代码来源:type.py


示例14: c_headers

    def c_headers(self, c_compiler):
        """
        Override `CLinkerObject.c_headers`.

        """
        return scal.get_scalar_type(self.dtype).c_headers(c_compiler)
开发者ID:ChinaQuants,项目名称:Theano,代码行数:6,代码来源:type.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python scalar.int32函数代码示例发布时间:2022-05-27
下一篇:
Python scalar.as_scalar函数代码示例发布时间: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