Giter VIP home page Giter VIP logo

da-rnn's Introduction

Hello there ๐Ÿ‘‹

visitors Open Source Love

#!/usr/bin/python
# -*- coding: utf-8 -*-


class SoftwareEngineer:

    def __init__(self):
        self.name = "Zhenye Na"
        self.role = "Software Engineer"
        self.language_spoken = ["zh_CN", "en_US"]

    def say_hi(self):
        print("Thanks for dropping by, hope you find some of my work interesting.")


me = SoftwareEngineer()
me.say_hi()

๐Ÿ“ Blogs

๐Ÿ“” Latest Blog posts

๐Ÿ”ง Technologies & Tools

Cloud Services:

AWS API Gateway DynamoDB AWS Lambda CloudWatch SQS

Programming Languages:

Java Python Go Rust

Tools and Services:

Kubernetes Docker

๐Ÿ† GitHub Trophies

trophy

๐Ÿ—‚๏ธ Highlight Projects

DA-RNN crnn-pytorch

da-rnn's People

Contributors

dan-r95 avatar imgbotapp avatar zhenye-na avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

da-rnn's Issues

I encountered an issue where the input and tags did not match when I ran your code.

I need some help. This is error!
File "F:/็ ”็ฉถ็”Ÿ่ต„ๆ–™/่ฎบๆ–‡/ๆณจๆ„ๅŠ›ๆœบๅˆถ/DA-RNN-master-pytorch/DA-RNN-master/src/main.py", line 55, in
model.train()

File "F:\็ ”็ฉถ็”Ÿ่ต„ๆ–™\่ฎบๆ–‡\ๆณจๆ„ๅŠ›ๆœบๅˆถ\DA-RNN-master-pytorch\DA-RNN-master\src\model.py", line 285, in train
loss = self.criterion(y_pred, y_true)

File "G:\Users\ll\Anaconda3\envs\tensorflow_gpu\lib\site-packages\torch\nn\modules\module.py", line 491, in call
result = self.forward(*input, **kwargs)

File "G:\Users\ll\Anaconda3\envs\tensorflow_gpu\lib\site-packages\torch\nn\modules\loss.py", line 372, in forward
return F.mse_loss(input, target, size_average=self.size_average, reduce=self.reduce)

File "G:\Users\ll\Anaconda3\envs\tensorflow_gpu\lib\site-packages\torch\nn\functional.py", line 1569, in mse_loss
input, target, size_average, reduce)

File "G:\Users\ll\Anaconda3\envs\tensorflow_gpu\lib\site-packages\torch\nn\functional.py", line 1537, in _pointwise_loss
return lambd_optimized(input, target, size_average, reduce)

RuntimeError: input and target shapes do not match: input [128 x 1], target [128] at c:\users\administrator\downloads\new-builder\win-wheel\pytorch\aten\src\thnn\generic/MSECriterion.c:13

why use companies' stock price to predict NASDAQ-100 Index?

your code in utils.py read_data(), the code of getting data is below, why do you use companies' stock price to predict NASDAQ-100 Index?
X = df.loc[:, [x for x in df.columns.tolist() if x != 'NDX']].as_matrix()
y = np.array(df.NDX)

NDX should be calculated by these stock prices, isnโ€™t it? why u have to learn the calculation formula by RNN?
The DA-RNN paper gives a time series predicting model, right? But where is your time series predicting? I am confusion.

That's what I found when I read the code repeatedly, If I got wrong or missed something, please tell me.
Thank you.

abut Eq 8

I found that the Eq 8 in the paper is different from the coding function in your program. The tanh function is not used, but your decoding function is consistent with the paper, Thanks!!!!!

GPU is not used

Thank you for your contribution, but I can't call GPU when I run this code. Here is my configuration.
Ubuntu18.04, CUDA9.0, cudnn7.0, pytorch0.3.0.

A problem about input data

Hello, author.

The input data includes drving series and previous values of the target series according to this paper. I am a little puzzeld about the drving series $X$ When I prepare to apply this model in my data. My data only have the previous values of the target series, How can I ready for the drving series ?

Please help me crack my quandary at your nearest free time.

Thanks !!!

Please reply

Dear Zhenye,
Could you please send me an email (should be visible on my profile). I compiled a detailed email to share with you, then realized your email wasn't public.
thanks,
Daniel

It seems that the training model failed.

Hi, Zhenye, thank you for excellent code. When i ran the code, it seemed that i got the wrong prediction result.
image Could you please give some advice on how to overcome it? Thanks a lot.

time step in y_prev y_gt

Thanks for the awesome code, I'm still learning DARNN, and a little bit confused in your code.

I've noticed that in training session, your y_prev is defined as

for bs in range(len(indices)):
y_prev[bs, :] = self.y[indices[bs]:(indices[bs] + self.T - 1)]

but y_gt is

y_gt = self.y[indices + self.T]

The question is,

If batchsize is 1, T is 10,

You get y[0:9](the 1st to the 9th number, let's say [0, 1, 2, 3, 4, 5, 6, 7, 8]) as input but predict y[10] as target(which is the 11th number, let's say [10] ).

Doesn't that means the code skips the 10th value as target? (value [9] )

Or I'm just wrong in numpy indexing.

RuntimeError: invalid argument 3: out of range

This is my data which I repaced in ../nasdaq/data.csv directory.
I need to train model for price detection, this is how my data look like:
image

For CPU, I run the python3 main.py --lr 0.0001 --epochs 50, but I got this error:

File "/content/drive/My Drive/Spot-Forcasting/paper-methods2019/DA-RNN/DA-RNN/src/model.py", line 77, in forward
x = torch.cat((h_n.repeat(self.input_size, 1, 1).permute(1, 0, 2),
RuntimeError: invalid argument 3: out of range at /pytorch/aten/src/TH/generic/THTensor.cpp:392

image

Any idea how to solve it?
Thanks

about Eq 8

I found that the Eq 8 in the paper is different from the coding function in your program. The tanh function is not used, but your decoding function is consistent with the paper, Thanks!!!!!

one bug when running the code

When I ran the code, there was a bug:''LSTM' object has no attribute 'flatten_parameters'',
Here is the code:
self.encoder_lstm.flatten_parameters()
_, final_stage = self.encoder_lstm(
x_tilde.unsqueeze(0), (h_n, s_n))
h_n = final_state[0]
s_n = final_stage[1]

I am not sure if this bug happened due to the naming issue

Is da-rnn useful for mult-step forcasting?

I tried da-rnn for multi-step forcasting but got very bad performance. I cut the dataset by the setting step length. And the strategy for multi-step is Multiple-Output. Is the attention mechanism not good for multi-step forcasting?

Defining a train method will break the model.eval() call.

Pytorch has a built in method which sets the model into evaluation mode. The method is called torch.nn.Module.eval(). In this method the train method is called with a parameter. Due to the case the your rnn also implements a train method python overwrites the default train method and the code will crash.
How to fix:
I recommend to rename your method into fit() or train_epochs() or something similiear.

Regardless of some minor issues, your model seems nice.

Only Report Training Loss?

It seems the train_val_test_split function in ops.py file is never called. The model is trained on all data points, and the training loss is reported.

Encoder error

Shouldn't the input to the encoder be from 1 to T instead of T-1?
As the number LSTM in stack for encoder is to T and decoder is 1 to T- 1,as per my understanding of the reference paper.
Thank you and hope we can discuss and resolve this issue

How can I enable cuda to accelerate training?

I run the program as follows, but it seems cuda is not enabled.
python3 main.py --cuda

So, I edited the part of source codes as following,
model = DA_rnn(X, y, opt.ntimestep, opt.nhidden_encoder, opt.nhidden_decoder, opt.batchsize, opt.lr, opt.epochs, opt.cuda)
I added "opt.cuda" parameter.

However, there are still problems like this:

/home/tatsuhiro/PycharmProjects/untitled/DA-RNN-master/src/model.py:80: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
alpha = F.softmax(x.view(-1, self.input_size))
/home/tatsuhiro/PycharmProjects/untitled/DA-RNN-master/src/model.py:145: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
x.view(-1, 2 * self.decoder_num_hidden + self.encoder_num_hidden)).view(-1, self.T - 1))
Traceback (most recent call last):
File "main.py", line 57, in
model.train()
File "/home/tatsuhiro/PycharmProjects/untitled/DA-RNN-master/src/model.py", line 260, in train
loss = self.train_forward(x, y_prev, y_gt)
File "/home/tatsuhiro/PycharmProjects/untitled/DA-RNN-master/src/model.py", line 316, in train_forward
loss = self.criterion(y_pred, y_true)
File "/home/tatsuhiro/PycharmProjects/untitled/venv/lib/python3.5/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/tatsuhiro/PycharmProjects/untitled/venv/lib/python3.5/site-packages/torch/nn/modules/loss.py", line 372, in forward
return F.mse_loss(input, target, size_average=self.size_average, reduce=self.reduce)
File "/home/tatsuhiro/PycharmProjects/untitled/venv/lib/python3.5/site-packages/torch/nn/functional.py", line 1569, in mse_loss
input, target, size_average, reduce)
File "/home/tatsuhiro/PycharmProjects/untitled/venv/lib/python3.5/site-packages/torch/nn/functional.py", line 1537, in _pointwise_loss
return lambd_optimized(input, target, size_average, reduce)
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #2 'target'

How can I solve this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.