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


Python functions.Linear方法代码示例

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

示例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), 
开发者ID:sisl,项目名称:Chimp,代码行数:16,代码来源:mountain_car_test.py

示例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)),
        ) 
开发者ID:sisl,项目名称:Chimp,代码行数:10,代码来源:run_atari.py

示例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), 
开发者ID:sisl,项目名称:Chimp,代码行数:16,代码来源:run_mountain_car.py

示例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), 
开发者ID:sisl,项目名称:Chimp,代码行数:16,代码来源:run_cartpole.py

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

示例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))
        ) 
开发者ID:ugo-nama-kun,项目名称:DQN-chainer,代码行数:12,代码来源:dqn_agent.py

示例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))
        ) 
开发者ID:ugo-nama-kun,项目名称:DQN-chainer,代码行数:11,代码来源:dqn_agent_cpu.py

示例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)] 
开发者ID:ugo-nama-kun,项目名称:DQN-chainer,代码行数:31,代码来源:dqn_agent_nips.py

示例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)] 
开发者ID:ugo-nama-kun,项目名称:DQN-chainer,代码行数:34,代码来源:dqn_agent_nature.py

示例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)] 
开发者ID:uei,项目名称:deel,代码行数:31,代码来源:q_net.py


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