Generalization in QML from few training data Demo

For Generalization in QML from few training data Demo:

Training for different training set sizes cell: The following error is received.


AttributeError Traceback (most recent call last)
in <cell line: 22>()
20 # run training for multiple sizes
21 train_sizes = [2, 5, 10, 20, 40, 80]
—> 22 results_df = run_iterations(n_train=2)
23 for n_train in train_sizes[1:]:
24 results_df = pd.concat([results_df, run_iterations(n_train=n_train)])

12 frames
[… skipping hidden 20 frame]

[... skipping hidden 12 frame]

[... skipping hidden 3 frame]

/usr/local/lib/python3.10/dist-packages/jax/_src/deprecations.py in getattr(name)
51 warnings.warn(message, DeprecationWarning, stacklevel=2)
52 return fn
—> 53 raise AttributeError(f"module {module!r} has no attribute {name!r}")
54
55 return getattr

AttributeError: module ‘jax’ has no attribute ‘ad’


Name: PennyLane
Version: 0.31.1
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: GitHub - PennyLaneAI/pennylane: PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.
Author:
Author-email:
License: Apache License 2.0
Location: /usr/local/lib/python3.10/dist-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane-Lightning

Platform info: Linux-5.15.109±x86_64-with-glibc2.35
Python version: 3.10.12
Numpy version: 1.23.5
Scipy version: 1.10.1
Installed devices:

Thank you,
Reference:

Hi @kevinkawchak ,

Can you please post the entire code that you changed with respect to the demo? This way I can try to replicate your error and help you.

@CatalinaAlbornoz, Thank you, I was able to run this demo now.

For a different demo, could you see if you receive this error for Quantum generative adversarial networks with Cirq + TensorFlow? Unmodified code, I tried running on two different IDEs.

AttributeError: ‘tensorflow.python.framework.ops.EagerTensor’ object has no attribute ‘_unique_id’

Reference:

Thank you.

Hi @kevinkawchak, I can replicate your error. Can you please open a new post so that we keep this one for generalization in QML? In the new post, can you please post the output of qml.about() and your versions of TensorFlow and Cirq?

Would you mind sharing what fixed this issue for the generalization demo? Because I’m having the same error.

Hello @Lucas_Tecot, these installs: Medical-Quantum-Machine-Learning/Code/All PennyLane QML Demos/36 GANs Cirq TensorFlow 29.5s kkawchak.ipynb at main · kevinkawchak/Medical-Quantum-Machine-Learning · GitHub