LouisScorpio / datamining

learn in datamining
522 stars 848 forks source link

你确定这代码能跑吗? #2

Closed JianghaoPi closed 7 years ago

JianghaoPi commented 7 years ago

那个stock_predict.py,import tensorflow as tf都没有,后面使用tf怎么能成功?还有那个rnn是哪里来的? 第二个stock_predict_2.py,会发生越界。请问能跑的代码是哪个版本?

qingaidexin commented 7 years ago

你好,我刚才运行stock_predict2.py 这个代码 ,报这个错诶  File "", line 10, in get_train_data y=normalized_train_data[i:i+time_step,7,np.newaxis]

IndexError: index 7 is out of bounds for axis 1 with size 7

LouisScorpio commented 7 years ago

@JianghaoPi 谢谢提醒。 以下是编辑错误,已在代码中修改。 import tensorflow 改成 import tensorflow as tf
rnn应该改成lstm 数据集已经换了一个 @qingaidexin 数据集的问题,已经换了一个

anxxxxx commented 7 years ago

楼主,目前提示错误,麻烦问下stock_predict_2.py 可以直接跑吗?需要调整什么吗?还是python和tensorflow是哪个版本的啊? ValueError: Variable first_lstm/RNN/BasicLSTMCell/Linear/Matrix already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:

File "stock_predict2.py", line 55, in lstm output_rnn,final_states=tf.nn.dynamic_rnn(cell, input_rnn,initial_state=init_state, dtype=tf.float32) File "stock_predict2.py", line 66, in trainlstm pred,=lstm(batch_size) File "stock_predict.py", line 86, in train_lstm()

LouisScorpio commented 7 years ago

@anxxxxx 你可以试试训练和测试分开进行

anxxxxx commented 7 years ago

谢谢楼主,跑通了!

Fei-FeiLiang commented 7 years ago

这个代码貌似跑不了啊

Fei-FeiLiang commented 7 years ago

@anxxxxx 怎么跑通的,可否说一下?谢谢哈!

anxxxxx commented 7 years ago

按照楼主说的,先注释掉预测,运行一次;再注释掉训练,预测一次,就OK了

axy5106@126.com

发件人: feifeiliang 发送时间: 2017-03-23 16:42 收件人: LouisScorpio/deeplearning 抄送: anxxxxx; Mention 主题: Re: [LouisScorpio/deeplearning] 你确定这代码能跑吗? (#2) @anxxxxx 怎么跑通的,可否说一下?谢谢哈! — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

auxs2015 commented 7 years ago

@anxxxxx 是不是环境的关系啊,我的tf是0.8,python 2.7还是报下面错:

Traceback (most recent call last): File "stock_predict_2.py", line 115, in train_lstm() File "stock_predict_2.py", line 97, in trainlstm pred,=lstm(X) File "stock_predict_2.py", line 80, in lstm input_rnn=tf.reshape(input_rnn,[-1,time_step,rnn_unit]) #��tensorת��3ά����Ϊlstm cell����� File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1092, in reshape name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/op_def_library.py", line 411, in apply_op as_ref=input_arg.is_ref) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 566, in convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/constant_op.py", line 179, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/constant_op.py", line 162, in constant tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape)) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 332, in make_tensor_proto _AssertCompatible(values, dtype) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 272, in _AssertCompatible (dtype.name, repr(mismatch), type(mismatch).name)) TypeError: Expected int32, got list containing Tensors of type '_Message' instead.