搭建Tensorflow Quantum编程环境(Jupyter Notebook)

搭建Tensorflow Quantum编译环境

  • python包之间的版本冲突:
    tensorflow-quantum依赖于cirq,而两个包对 protobuf 包的版本有要求(cirq需要protobuf版本为3.8.0,tensorflow-2.2.0最低要求是protobuf-3.8.0,更高版本的tensorflow要求更高版本的protobuf,会造成版本冲突):
cirq-0.8.0 <- -  protobuf-3.8.0
tenforflow-2.2.0 (protobuf >= 3.8.0)
  • 环境搭建步骤(打开anaconda prompt,输入指令):
  1. 在anaconda中创建新的环境(python 3.6 或 3.7 都可以)
conda create --name tensorflowq python=3.7
  1. 安装tensorflow和tensorflow-quantum包
conda activate tensorflowq
pip install tensorflow==2.2.0
pip install tensorflow-quantum
  1. 将环境配置到jupyter notebook
pip install ipykernel
python -m ipykernel install --user --name tensorflowq

#jupyter kernelspec remove kernelname #如不使用了,可使用该语句删除kernel
  1. 在 jupyter notebook 中测试环境
import cirq
import tensorflow_quantum as tfq

编译通过即配置成功!

你可能感兴趣的:(量子机器学习,tensorflow)