本文整理汇总了Python中PyTorch.require方法的典型用法代码示例。如果您正苦于以下问题:Python PyTorch.require方法的具体用法?Python PyTorch.require怎么用?Python PyTorch.require使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyTorch
的用法示例。
在下文中一共展示了PyTorch.require方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nnx
# 需要导入模块: import PyTorch [as 别名]
# 或者: from PyTorch import require [as 别名]
def test_nnx():
# net = nn.Minus()
inputTensor = PyTorch.DoubleTensor(2, 3).uniform()
print("inputTensor", inputTensor)
PyTorch.require("nnx")
net = nn.Minus()
print(net.forward(inputTensor))
示例2: load_lua_class
# 需要导入模块: import PyTorch [as 别名]
# 或者: from PyTorch import require [as 别名]
def load_lua_class(lua_filename, lua_classname):
module = lua_filename.replace('.lua', '')
PyTorch.require(module)
splitName = lua_classname.split('.')
class LuaWrapper(PyTorchAug.LuaClass):
def __init__(self, *args):
_fromLua = False
if len(args) >= 1:
if args[0] == '__FROMLUA__':
_fromLua = True
args = args[1:]
# print('LuaWrapper.__init__', lua_classname, 'fromLua', _fromLua, 'args', args)
self.luaclass = lua_classname
if not _fromLua:
PyTorchAug.LuaClass.__init__(self, splitName, *args)
else:
self.__dict__['__objectId'] = PyTorchAug.getNextObjectId()
renamedClass = PyTorchLua.renameClass(LuaWrapper, module, lua_classname)
return renamedClass
示例3:
# 需要导入模块: import PyTorch [as 别名]
# 或者: from PyTorch import require [as 别名]
from __future__ import print_function
import PyTorch
PyTorch.require('rnn')
from PyTorchAug import nn
lstm = nn.LSTM(3,4)
print('lstm', lstm)
示例4: Luabit
# 需要导入模块: import PyTorch [as 别名]
# 或者: from PyTorch import require [as 别名]
import sys
import os
import PyTorchAug
import PyTorch
import numpy as np
PyTorch.require('luabit')
class Luabit(PyTorchAug.LuaClass):
def __init__(self, _fromLua=False):
self.luaclass = 'Luabit'
if not _fromLua:
name = self.__class__.__name__
super(self.__class__, self).__init__([name])
else:
self.__dict__['__objectId'] = getNextObjectId()
batchSize = 2
numFrames = 4
inSize = 3
outSize = 3
kernelSize = 3
luabit = Luabit()
inTensor = np.random.randn(batchSize, numFrames, inSize).astype('float32')
luain = PyTorch.asFloatTensor(inTensor)
luaout = luabit.getOut(luain, outSize, kernelSize)
outTensor = luaout.asNumpyTensor()
print('outTensor', outTensor)
示例5: print
# 需要导入模块: import PyTorch [as 别名]
# 或者: from PyTorch import require [as 别名]
from __future__ import print_function
import PyTorch
from PyTorchAug import nn
PyTorch.require("rnn")
if __name__ == "__main__":
lstm = nn.LSTM(3, 4)
print("lstm", lstm)