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]

你可能感兴趣的:(论文,编程学习)