DQN算法中的部分代码

if-else的一种简写:

e_greedy_increment = None
epsilon_max = 0.9
epsilon = 0 if e_greedy_increment is not None else epsilon_max
print(epsilon)

结果为: 0.9

如果e_greedy_increment没有值,则self.epsilon设置为self.epsilon_max=0.9


一维数组:

import numpy as np
num_episodes = 10000
rewards = np.zeros(num_episodes)
print(rewards)
print(len(rewards))

结果为:

[0. 0. 0. ... 0. 0. 0.]
10000

np.array:

import numpy as np

action = []
for i in range(5):
    action.append(i)
arr_actions = np.array(action)
print(arr_actions)

结果为:

[0 1 2 3 4]

数组元素的操作:

import numpy as np
L1 = np.zeros(5, dtype=int)
for i in range(5):
    L1[i] = i + 1
print(L1)

结果为:

[1 2 3 4 5]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值