tensorflow玩轉量化交易-python version相容問題
code from https://github.com/borenwu/topquant
pip install tensorflow==1.3.0
pip install numpy==1.16.4
pip install flask-restx==0.1.1
pip install keras==2.0.7
-- 2-1
import tensorflow as tf
import pandas as pd
pd.set_option('display.width',450)
fss='data/600663.csv'
df=pd.read_csv(fss,index_col=0)
print(df.tail())
--
今天狠心把tensorflow玩轉量化交易這本書拿起來K
實作第一個程式時 就不斷地翻車
原因都在版本相容性問題
至少我們以前學C++學JAVA都沒有這種問題
答案都只有一個
這也是開放的原罪
首先pip太新 必須把舊的pip安裝回來 不然python一直跟你靠北
python -m ensurepip
再來現在線上安裝tensorflow都是2.8以上
書上1.3寫的程式完全不能跑
像tflearn = ft.contrib.learn
暫時寫成
>>> tflean = tf.compat.v1.nn.rnn_cell.RNNCell.state_size
讓他過
>>> print(tl.__version__);
2.2.3
>>> print(tf.__version__);
2.8.0-rc1
2.8.0-rc1
>>> print(ks.__version__);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ks' is not defined
>>> import keras as ks
>>> print(ks.__version__);
2.8.0
>>> import pandas as pd
>>> print(pd.__version__);
1.4.0
>>> import tushare as ts
>>> print(ts.__version__);
1.2.83
>>> import matplotlib as mpl
>>> print(mpl.__version__);
3.5.1
>>> print(plotly.__version__);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'plotly' is not defined
>>> import plotly as pl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'plotly'
>>> print(arrow.__version__);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'arrow' is not defined
>>> import arrow
>>> print(arrow.__version__);
1.2.2
然後一直跟我靠杯沒有GPU
我瓊不行嗎
cfig=tf.ConfigProto(log_device_placement=True)
留言
張貼留言