1 Star 0 Fork 0

zeng/pytracking

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
base_actor.py 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
goutam 提交于 6年前 . adding ltr
from pytracking import TensorDict
class BaseActor:
""" Base class for actor. The actor class handles the passing of the data through the network
and calculation the loss"""
def __init__(self, net, objective):
"""
args:
net - The network to train
objective - The loss function
"""
self.net = net
self.objective = objective
def __call__(self, data: TensorDict):
""" Called in each training iteration. Should pass in input data through the network, calculate the loss, and
return the training stats for the input data
args:
data - A TensorDict containing all the necessary data blocks.
returns:
loss - loss for the input data
stats - a dict containing detailed losses
"""
raise NotImplementedError
def to(self, device):
""" Move the network to device
args:
device - device to use. 'cpu' or 'cuda'
"""
self.net.to(device)
def train(self, mode=True):
""" Set whether the network is in train mode.
args:
mode (True) - Bool specifying whether in training mode.
"""
self.net.train(mode)
def eval(self):
""" Set network to eval mode"""
self.train(False)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zengzheming/pytracking.git
git@gitee.com:zengzheming/pytracking.git
zengzheming
pytracking
pytracking
master

搜索帮助