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


Python PyTorch.require方法代码示例

本文整理汇总了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))
开发者ID:hughperkins,项目名称:pytorch,代码行数:10,代码来源:test_nnx.py

示例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
开发者ID:3upperm2n,项目名称:pytorch,代码行数:21,代码来源:PyTorchHelpers.py

示例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)

开发者ID:3upperm2n,项目名称:pytorch,代码行数:11,代码来源:test_rnn.py

示例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)
开发者ID:ChrisYang,项目名称:pytorch,代码行数:33,代码来源:pybit.py

示例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)
开发者ID:hughperkins,项目名称:pytorch,代码行数:12,代码来源:test_rnn.py


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