MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / get_config

Function get_config

examples/DeepQNetwork/DQN.py:102–142  ·  view source on GitHub ↗
(model)

Source from the content-addressed store, hash-verified

100
101
102def get_config(model):
103 global args
104 expreplay = ExpReplay(
105 predictor_io_names=(['state'], ['Qvalue']),
106 get_player=lambda: get_player(train=True),
107 num_parallel_players=NUM_PARALLEL_PLAYERS,
108 state_shape=model.state_shape,
109 batch_size=BATCH_SIZE,
110 memory_size=MEMORY_SIZE,
111 init_memory_size=INIT_MEMORY_SIZE,
112 update_frequency=UPDATE_FREQ,
113 history_len=FRAME_HISTORY,
114 state_dtype=model.state_dtype.as_numpy_dtype
115 )
116
117 # Set to other values if you need a different initial exploration
118 # (e.g., # if you're resuming a training half-way)
119 # expreplay.exploration = 1.0
120
121 return TrainConfig(
122 data=QueueInput(expreplay),
123 model=model,
124 callbacks=[
125 ModelSaver(),
126 PeriodicTrigger(
127 RunOp(DQNModel.update_target_param, verbose=True),
128 every_k_steps=5000), # update target network every 5k steps
129 expreplay,
130 ScheduledHyperParamSetter('learning_rate',
131 [(0, 1e-3), (60, 5e-4), (400, 1e-4)]),
132 ScheduledHyperParamSetter(
133 ObjAttrParam(expreplay, 'exploration'),
134 [(0, 1), (10, 0.1), (400, 0.01)], # 1->0.1 in the first million steps
135 interp='linear'),
136 PeriodicTrigger(Evaluator(
137 args.num_eval, ['state'], ['Qvalue'], get_player),
138 every_k_epochs=5 if 'pong' in args.env.lower() else 10), # eval more frequently for easy games
139 ],
140 steps_per_epoch=STEPS_PER_EPOCH,
141 max_epoch=500, # a total of 50M state transition
142 )
143
144
145if __name__ == '__main__':

Callers 1

DQN.pyFile · 0.70

Calls 10

ExpReplayClass · 0.90
EvaluatorClass · 0.90
TrainConfigClass · 0.85
QueueInputClass · 0.85
ModelSaverClass · 0.85
PeriodicTriggerClass · 0.85
RunOpClass · 0.85
ObjAttrParamClass · 0.85
get_playerFunction · 0.70

Tested by

no test coverage detected