本文整理汇总了Python中chainer.functions.Linear方法的典型用法代码示例。如果您正苦于以下问题:Python functions.Linear方法的具体用法?Python functions.Linear怎么用?Python functions.Linear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainer.functions
的用法示例。
在下文中一共展示了functions.Linear方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self):
super(Linear, self).__init__(
l1=F.Bilinear(settings["n_frames"], settings["n_frames"], 200),
l2=F.Linear(200, 100, wscale=np.sqrt(2)),
l3=F.Linear(100, 100, wscale=np.sqrt(2)),
l4=F.Linear(100, 50, wscale=np.sqrt(2)),
l5=F.Linear(50, simulator.n_actions, wscale = np.sqrt(2))
)
示例2: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self):
super(TestNet, self).__init__(
l1=F.Linear(settings['model_dims'][1], 20, bias=0.0),
l2=F.Linear(20, 10, bias=0.0),
bn1=L.BatchNormalization(10),
l3=F.Linear(10, 10),
l4=F.Linear(10, 10),
bn2=L.BatchNormalization(10),
lout=F.Linear(10, simulator.n_actions)
)
self.train = True
# initialize avg_var to prevent divide by zero
self.bn1.avg_var.fill(0.1),
self.bn2.avg_var.fill(0.1),
示例3: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self):
super(Convolution, self).__init__(
l1=F.Convolution2D(settings['history_sizes'][0], 32, ksize=8, stride=4, nobias=False, wscale=np.sqrt(2)),
l2=F.Convolution2D(32, 64, ksize=4, stride=2, nobias=False, wscale=np.sqrt(2)),
l3=F.Convolution2D(64, 64, ksize=3, stride=1, nobias=False, wscale=np.sqrt(2)),
l4=F.Linear(3136, 512, wscale = np.sqrt(2)),
l5=F.Linear(512, simulator.n_actions, wscale = np.sqrt(2)),
)
示例4: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self):
super(CarNet, self).__init__(
l1=F.Linear(settings['model_dims'][1], 20, bias=0.0),
l2=F.Linear(20, 10, bias=0.0),
bn1=L.BatchNormalization(10),
l3=F.Linear(10, 10),
l4=F.Linear(10, 10),
bn2=L.BatchNormalization(10),
lout=F.Linear(10, simulator.n_actions)
)
self.train = True
# initialize avg_var to prevent divide by zero
self.bn1.avg_var.fill(0.1),
self.bn2.avg_var.fill(0.1),
示例5: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self):
super(CartNet, self).__init__(
l1=F.Linear(4, 20, bias=0.0),
l2=F.Linear(20, 10, bias=0.0),
bn1=L.BatchNormalization(10),
l3=F.Linear(10, 10),
l4=F.Linear(10, 10),
bn2=L.BatchNormalization(10),
lout=F.Linear(10, simulator.n_actions)
)
self.train = True
# initialize avg_var to prevent divide by zero
self.bn1.avg_var.fill(0.1),
self.bn2.avg_var.fill(0.1),
示例6: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self, action, other_action, size, epsilon=0.05, hidden=200):
self.action = action
self.other_action = other_action
self.width = size * size
self.epsilon = epsilon
self.hidden = hidden
super(ChainerAgent, self).__init__(
l1=F.Linear(self.width, self.hidden, wscale=np.sqrt(2)),
l2=F.Linear(self.hidden, 1, wscale=np.sqrt(2)),
)
示例7: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self, n_history, n_act):
super(ActionValue, self).__init__(
l1=F.Convolution2D(n_history, 32, ksize=8, stride=4, nobias=False, wscale=np.sqrt(2)),
l2=F.Convolution2D(32, 64, ksize=4, stride=2, nobias=False, wscale=np.sqrt(2)),
l3=F.Convolution2D(64, 64, ksize=3, stride=1, nobias=False, wscale=np.sqrt(2)),
l4=F.Linear(3136, 512, wscale=np.sqrt(2)),
q_value=F.Linear(512, n_act,
initialW=np.zeros((n_act, 512),
dtype=np.float32))
)
示例8: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self, n_history, n_act):
super(ActionValue, self).__init__(
l1=F.Convolution2D(n_history, 32, ksize=8, stride=4, nobias=False, wscale=np.sqrt(2)),
l2=F.Convolution2D(32, 64, ksize=4, stride=2, nobias=False, wscale=np.sqrt(2)),
l3=F.Convolution2D(64, 64, ksize=3, stride=1, nobias=False, wscale=np.sqrt(2)),
l4=F.Linear(3136, 512),#, wscale=np.sqrt(2)),
q_value=F.Linear(512, n_act,
initialW=0.0*np.random.randn(n_act, 512).astype(np.float32))
)
示例9: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self, enable_controller=[0, 3, 4]):
self.num_of_actions = len(enable_controller)
self.enable_controller = enable_controller # Default setting : "Pong"
print "Initializing DQN..."
# Initialization for Chainer 1.1.0 or older.
# print "CUDA init"
# cuda.init()
print "Model Building"
self.model = FunctionSet(
l1=F.Convolution2D(4, 16, ksize=8, stride=4, wscale=np.sqrt(2)),
l2=F.Convolution2D(16, 32, ksize=4, stride=2, wscale=np.sqrt(2)),
l3=F.Linear(2592, 256),
q_value=F.Linear(256, self.num_of_actions,
initialW=np.zeros((self.num_of_actions, 256),
dtype=np.float32))
).to_gpu()
print "Initizlizing Optimizer"
self.optimizer = optimizers.RMSpropGraves(lr=0.0002, alpha=0.3, momentum=0.2)
self.optimizer.setup(self.model.collect_parameters())
# History Data : D=[s, a, r, s_dash, end_episode_flag]
self.D = [np.zeros((self.data_size, 4, 84, 84), dtype=np.uint8),
np.zeros(self.data_size, dtype=np.uint8),
np.zeros((self.data_size, 1), dtype=np.int8),
np.zeros((self.data_size, 4, 84, 84), dtype=np.uint8),
np.zeros((self.data_size, 1), dtype=np.bool)]
示例10: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self, enable_controller=[0, 3, 4]):
self.num_of_actions = len(enable_controller)
self.enable_controller = enable_controller # Default setting : "Pong"
print "Initializing DQN..."
# Initialization of Chainer 1.1.0 or older.
# print "CUDA init"
# cuda.init()
print "Model Building"
self.model = FunctionSet(
l1=F.Convolution2D(4, 32, ksize=8, stride=4, nobias=False, wscale=np.sqrt(2)),
l2=F.Convolution2D(32, 64, ksize=4, stride=2, nobias=False, wscale=np.sqrt(2)),
l3=F.Convolution2D(64, 64, ksize=3, stride=1, nobias=False, wscale=np.sqrt(2)),
l4=F.Linear(3136, 512, wscale=np.sqrt(2)),
q_value=F.Linear(512, self.num_of_actions,
initialW=np.zeros((self.num_of_actions, 512),
dtype=np.float32))
).to_gpu()
self.model_target = copy.deepcopy(self.model)
print "Initizlizing Optimizer"
self.optimizer = optimizers.RMSpropGraves(lr=0.00025, alpha=0.95, momentum=0.95, eps=0.0001)
self.optimizer.setup(self.model.collect_parameters())
# History Data : D=[s, a, r, s_dash, end_episode_flag]
self.D = [np.zeros((self.data_size, 4, 84, 84), dtype=np.uint8),
np.zeros(self.data_size, dtype=np.uint8),
np.zeros((self.data_size, 1), dtype=np.int8),
np.zeros((self.data_size, 4, 84, 84), dtype=np.uint8),
np.zeros((self.data_size, 1), dtype=np.bool)]
示例11: __init__
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import Linear [as 别名]
def __init__(self, use_gpu, enable_controller, dim):
self.use_gpu = use_gpu
self.num_of_actions = len(enable_controller)
self.enable_controller = enable_controller
self.dim = dim
print("Initializing Q-Network...")
hidden_dim = 256
self.model = FunctionSet(
l4=F.Linear(self.dim*self.hist_size, hidden_dim, wscale=np.sqrt(2)),
q_value=F.Linear(hidden_dim, self.num_of_actions,
initialW=np.zeros((self.num_of_actions, hidden_dim),
dtype=np.float32))
)
if self.use_gpu >= 0:
self.model.to_gpu()
self.model_target = copy.deepcopy(self.model)
self.optimizer = optimizers.RMSpropGraves(lr=0.00025, alpha=0.95, momentum=0.95, eps=0.0001)
self.optimizer.setup(self.model.collect_parameters())
# History Data : D=[s, a, r, s_dash, end_episode_flag]
self.d = [np.zeros((self.data_size, self.hist_size, self.dim), dtype=np.uint8),
np.zeros(self.data_size, dtype=np.uint8),
np.zeros((self.data_size, 1), dtype=np.int8),
np.zeros((self.data_size, self.hist_size, self.dim), dtype=np.uint8),
np.zeros((self.data_size, 1), dtype=np.bool)]