ageron / ageron/handson-ml2

Chap18 Creating the DQN: ValueError: Variables lengths do not match between Q network and target network

Đang mở
#266 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Jupyter Notebook
Star
30k
Fork
13.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

When I run the first chank of the code titled "Creating the DQN" in Chapter 18, I got the following error:

```
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in ()
21 gamma=0.99, # discount factor
22 train_step_counter=train_step,
---> 23 epsilon_greedy=lambda: epsilon_fn(train_step))
24 agent.initialize()

6 frames
/usr/local/lib/python3.6/dist-packages/gin/config.py in gin_wrapper(*args, **kwargs)
1076 scope_info = " in scope '{}'".format(scope_str) if scope_str else ''
1077 err_str = err_str.format(name, fn_or_cls, scope_info)
-> 1078 utils.augment_exception_message_and_reraise(e, err_str)
1079
1080 return gin_wrapper

/usr/local/lib/python3.6/dist-packages/gin/utils.py in augment_exception_message_and_reraise(exception, message)
47 if six.PY3:
48 ExceptionProxy.__qualname__ = type(exception).__qualname__
---> 49 six.raise_from(proxy.with_traceback(exception.__traceback__), None)
50 else:
51 six.reraise(proxy, None, sys.exc_info()[2])

/usr/local/lib/python3.6/dist-packages/six.py in raise_from(value, from_value)

/usr/local/lib/python3.6/dist-packages/gin/config.py in gin_wrapper(*args, **kwargs)
1053
1054 try:
-> 1055 return fn(*new_args, **new_kwargs)
1056 except Exception as e: # pylint: disable=broad-except
1057 err_str = ''

/usr/local/lib/python3.6/dist-packages/tf_agents/agents/dqn/dqn_agent.py in __init__(self, time_step_spec, action_spec, q_network, optimizer, observation_and_action_constraint_splitter, epsilon_greedy, n_step_update, boltzmann_temperature, emit_log_probability, target_q_network, target_update_tau, target_update_period, td_errors_loss_fn, gamma, reward_scale_factor, gradient_clipping, debug_summaries, summarize_grads_and_vars, train_step_counter, name)
236 self._target_q_network = common.maybe_copy_target_network_with_checks(
237 self._q_network, target_q_network, input_spec=net_observation_spec,
--> 238 name='TargetQNetwork')
239
240 self._check_network_output(self._q_network, 'q_network')

/usr/local/lib/python3.6/dist-packages/tf_agents/utils/common.py in maybe_copy_target_network_with_checks(network, target_network, name, input_spec)
1281 # with the team.
1282 check_no_shared_variables(network, target_network)
-> 1283 check_matching_networks(network, target_network)
1284 return target_network
1285

/usr/local/lib/python3.6/dist-packages/tf_agents/utils/common.py in check_matching_networks(network_1, network_2)
1261 raise ValueError(
1262 'Variables lengths do not match between Q network and target network: '
-> 1263 '{} vs. {}'.format(network_1.variables, network_2.variables))
1264 for v1, v2 in zip(network_1.variables, network_2.variables):
1265 if v1.dtype != v2.dtype or v1.shape != v2.shape:

ValueError: Variables lengths do not match between Q network and target network: [, , , , , , , , , , ] vs. [, , , , , , , , , ]
In call to configurable 'DqnAgent' ()
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.