本文整理汇总了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;未经允许,请勿转载。 |
请发表评论