tensorflow玩轉量化交易-python version相容問題

code from https://github.com/borenwu/topquant


future: https://ithelp.ithome.com.tw/questions/10196572

相關版號請參閱1-7頁

python 3.6.4

pip install tensorflow==1.3.0

pip install tensorflow-gpu==1.3.0
REM Importerror: cannot import name moving_averages error occurs when we do not have TensorFlow-GPU installed.

pip install numpy==1.16.4

pip install flask-restx==0.1.1

pip install keras==2.0.7

pip install tflearn==0.3.2

pip install pandas==0.20.3

REM 2-3

pip install plotly==2.0.15

pip install arrow==0.10.0

pip install bs4

pip install numexpr

pip install psutil

pip install tushare

pip install  matplotlib==2.0.2

pip install robobrowser

pip install sklearn



-- 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)







留言

這個網誌中的熱門文章

10.29 Slow HTTP Denial of Service Attack (Slowloris)

在CentOS 8 Stream安裝NTP Client與設定時區

Update Pattern of TrendMicro AntiVirus Software - ServerProtect