本文整理汇总了Python中PyTorch._asByteTensor方法的典型用法代码示例。如果您正苦于以下问题:Python PyTorch._asByteTensor方法的具体用法?Python PyTorch._asByteTensor怎么用?Python PyTorch._asByteTensor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyTorch
的用法示例。
在下文中一共展示了PyTorch._asByteTensor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pushSomething
# 需要导入模块: import PyTorch [as 别名]
# 或者: from PyTorch import _asByteTensor [as 别名]
def pushSomething(lua, something):
if isinstance(something, int):
lua.pushNumber(something)
return
if isinstance(something, float):
lua.pushNumber(something)
return
if isinstance(something, str):
lua.pushString(something)
return
if isinstance(something, dict):
pushTable(lua, something)
return
if isinstance(something, list):
pushArray(lua, something)
return
for pythonClass in pushFunctionByPythonClass:
if isinstance(something, pythonClass):
pushFunctionByPythonClass[pythonClass](something)
return
if type(something) in luaClassesReverse:
pushObject(lua, something)
return
typestring = str(type(something))
if typestring in ["<class 'numpy.ndarray'>", "<type 'numpy.ndarray'>"]:
dtypestr = str(something.dtype)
if dtypestr == 'float32':
pushSomething(lua, PyTorch._asFloatTensor(something))
return
if dtypestr == 'float64':
pushSomething(lua, PyTorch._asDoubleTensor(something))
return
if dtypestr == 'uint8':
pushSomething(lua, PyTorch._asByteTensor(something))
return
raise Exception('pushing numpy array with elements of type ' + dtypestr + ' it not currently implemented')
raise Exception('pushing type ' + str(type(something)) + ' not implemented, value ', something)
示例2: asByteTensor
# 需要导入模块: import PyTorch [as 别名]
# 或者: from PyTorch import _asByteTensor [as 别名]
def asByteTensor(myarray):
f1 = PyTorch._asByteTensor(myarray)
# print('type(f1)', type(f1))
return ByteTensor(f1)