Giter Club home page Giter Club logo

atfm's People

Contributors

liulingbo918 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

Watchers

 avatar  avatar  avatar

atfm's Issues

Call ConvLSTM with gru=true

class ConvLSTM(nn.Module):
def init(self, in_channels, height, width, lstm_channels=16, all_hidden=False,
mode='merge', cpt=None, dropout_rate=0.5, last_conv=False,
conv_channels=None, gru=False)

When I call ConvLSTM with gru=true the execution goes just fine for run/train BikeNYC dataset.
However test BikeNYC gives following error.

incomplete days: []
after removing 4392
Preprocessing: Min max normalizing
DataFetcher: With Length: 4, 2, 0; with Padding: 0 0, 0 0; with Interval: 1 7.
Dumped 0 data.
Traceback (most recent call last):
File "test_bikenyc.py", line 105, in
test(dconf)
File "test_bikenyc.py", line 68, in test
model = model.cuda()
AttributeError: 'collections.OrderedDict' object has no attribute 'cuda'

Any help or clue?

Visualising results

Hi,
Thank you for the work. I have a question about TaxiBJ dataset. How do you visualise results? Also, why is there two different mse - inbound and outbound?

Please advise.

Thank you!

For the TaxiBJ

Hi
It seems that TaxiBJ could not download from the url
Can you please provide other ways to download this dataset?
Thanks a lot

No Data

i am not able to find data from link that you provide [data is remove ] ( from where can find data Taxibj and bikeNyc)

Applying multiplicative LSTM in ATFM model for short term prediction

I need your help in mLSTM model incorporation - added following implementation:
FIle: # model.layer.conv_lstm

class mLSTMCell(nn.Module):
def init(self, input_size, hidden_size, embed_size, output_size):
super(mLSTMCell, self).init()

    self.in_channels = in_channels
    self.height = height
    self.width = width 
    self.lstm_channels = lstm_channels

    self.hidden_size = hidden_size
    # input embedding
    self.encoder = nn.Embedding(input_size, embed_size)
    # lstm weights
    self.weight_fm = nn.Linear(hidden_size, hidden_size)
    self.weight_im = nn.Linear(hidden_size, hidden_size)
    self.weight_cm = nn.Linear(hidden_size, hidden_size)
    self.weight_om = nn.Linear(hidden_size, hidden_size)
    self.weight_fx = nn.Linear(embed_size, hidden_size)
    self.weight_ix = nn.Linear(embed_size, hidden_size)
    self.weight_cx = nn.Linear(embed_size, hidden_size)
    self.weight_ox = nn.Linear(embed_size, hidden_size)
    # multiplicative weights
    self.weight_mh = nn.Linear(hidden_size, hidden_size)
    self.weight_mx = nn.Linear(embed_size, hidden_size)
    # decoder
    self.decoder = nn.Linear(hidden_size, output_size)


def forward(self, input, state):
    h_0, c_0 = state
    inp = input
    # encode the input characters
    inp = self.encoder(inp)
    # calculate the multiplicative matrix
    m_t = self.weight_mx(inp) * self.weight_mh(h_0)
    # forget gate
    f_g = F.sigmoid(self.weight_fx(inp) + self.weight_fm(m_t))
    # input gate
    i_g = F.sigmoid(self.weight_ix(inp) + self.weight_im(m_t))
    # output gate
    o_g = F.sigmoid(self.weight_ox(inp) + self.weight_om(m_t))
    # intermediate cell state
    c_tilda = F.tanh(self.weight_cx(inp) + self.weight_cm(m_t))
    # current cell state
    cx = f_g * c_0 + i_g * c_tilda
    # hidden state
    hx = o_g * F.tanh(cx)

    out = self.decoder(hx.view(1,-1))

    #return out, hx, cx
    return hx, cx

def init_hidden(self):
    h_0 = Variable(torch.zeros(1, self.hidden_size)).cuda()
    c_0 = Variable(torch.zeros(1, self.hidden_size)).cuda()
    return h_0, c_0

and change the lstm_layer function as follows:

def lstm_layer(self, inputs):
n_in, c_in, h_in, w_in = inputs.size()

    if self.model_type == 'gru':
        state = torch.zeros(n_in, self.lstm_channels, h_in, w_in).cuda()
    elif self.model_type == 'lstm':
        state = (torch.zeros(n_in, self.lstm_channels, h_in, w_in).cuda(),
                 torch.zeros(n_in, self.lstm_channels, h_in, w_in).cuda())
    else: # if self.model_type == 'mlstm':
        state = (torch.zeros(n_in, self.lstm_channels, h_in, w_in).cuda(),
                 torch.zeros(n_in, self.lstm_channels, h_in, w_in).cuda())


    seq = torch.split(inputs, self.in_channels, dim=1)
    hiddent_list = []
    for idx, input in enumerate(seq[::-1]): # using reverse order
        state = self._lstm_cell(input, state)
        if self.model_type == 'gru':
            hidden = state
        elif self.model_type == 'lstm':
            hidden = state[0]
        else: # if self.model_type == 'mlstm':
            hidden = state[0]

        if self.last_conv:
            if self.conv_channels is None:
                raise ValueError('Parameter Out Channel is needed to enable last_conv')
            hidden = self._conv_layer(hidden)

        hiddent_list.append(hidden)
    
    if not self.all_hidden:
        return hiddent_list[-1]
    else:
        hiddent_list.reverse()
        return torch.cat(hiddent_list, 1)

def forward(self, inputs):
    if self.dropout_rate > 0:
        inputs = self._dropout_layer(inputs)
    if self.mode == 'merge':
        output = self.lstm_layer(inputs)
        return output
    elif self.mode == 'cpt':
        if self.cpt is None:
            raise ValueError('Parameter \'cpt\' is required in mode \'cpt\' of ConvLSTM')
        cpt_seq = split_cpt(inputs, self.cpt)
        output_list = [
            self.lstm_layer(input_) for input_ in cpt_seq
        ] 
        output = torch.cat(output_list, 1)
        return output
    else:
        raise('Invalid LSTM mode: '+self.mode)

I am getting error. It is not working. If you help me in this regard to implement mLSTM I will be greatful.

In case you nedd the modified source code or any information, please write in here.
thank you.
Basharat

spn-long

Hello! I did not find the spn-long model in github, only the spn model for short-term prediction. Could you please tell me where it is? Thank you!

Wondering how to apply ARIMA and VAR on BikeNYC dataset?

When we have following data structure:

BikeNYC dataset is a hdf5 file named NYC14_M16x8_T60_NewEnd.h5, which includes two subsets:

  • date: a list of timeslots, which is associated the data.
  • data: a 4D tensor of shape (number_of_timeslots, 2, 16, 8), of which data[i] is a 3D tensor of shape (2, 16, 8) at the timeslot date[i], data[i][0] is a 16x8 new-flow matrix and data[i][1] is a 16x8 end-flow matrix.

Wondering how to apply arima and var on BikeNYC dataset when both alrogithms expect 2D data and in here we have more dimensions.
How did you apply data conversion in this paper?

AttributeError: Can't pickle local object 'Dataset.load_data.<locals>.TempClass'

Good day,
Hope this met you well. I tried replication this result this is the error i am having, could you please help me out if possible?
Thank you

THE ERROR MESSAGE HERE
Preprocessing: Reading HDF5 file(s)
Dataset: BikeNYC
C:\Users\s324770\AppData\Local\Continuum\anaconda3\lib\site-packages\h5py_hl\dataset.py:313: H5pyDeprecationWarning: dataset.value has been deprecated. Use dataset[()] instead.
"Use dataset[()] instead.", H5pyDeprecationWarning)
before removing 4392
incomplete days: []
after removing 4392
Preprocessing: Min max normalizing
DataFetcher: With Length: 4, 2, 0; with Padding: 0 0, 0 0; with Interval: 1 7.
Dumped 0 data.
Set lr= 0.0003

AttributeError Traceback (most recent call last)
~\Dropbox\Implement2020\Codes\Attentive Crowd Flow Machines\run_bikenyc.py in
178 tconf = TrainConfiguration()
179
--> 180 run(dconf, tconf)

~\Dropbox\Implement2020\Codes\Attentive Crowd Flow Machines\run_bikenyc.py in run(dconf, tconf)
132
133 model.train()
--> 134 for i, (X, X_ext, Y, Y_ext) in enumerate(train_loader, 0):
135 X = X.cuda()
136 X_ext = X_ext.cuda()

~\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data\dataloader.py in iter(self)
277 return _SingleProcessDataLoaderIter(self)
278 else:
--> 279 return _MultiProcessingDataLoaderIter(self)
280
281 @Property

~\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data\dataloader.py in init(self, loader)
717 # before it starts, and del tries to join but will get:
718 # AssertionError: can only join a started process.
--> 719 w.start()
720 self._index_queues.append(index_queue)
721 self._workers.append(w)

~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\process.py in start(self)
110 'daemonic processes are not allowed to have children'
111 _cleanup()
--> 112 self._popen = self._Popen(self)
113 self._sentinel = self._popen.sentinel
114 # Avoid a refcycle if the target function holds an indirect

~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
221 @staticmethod
222 def _Popen(process_obj):
--> 223 return _default_context.get_context().Process._Popen(process_obj)
224
225 class DefaultContext(BaseContext):

~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
320 def _Popen(process_obj):
321 from .popen_spawn_win32 import Popen
--> 322 return Popen(process_obj)
323
324 class SpawnContext(BaseContext):

~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\popen_spawn_win32.py in init(self, process_obj)
87 try:
88 reduction.dump(prep_data, to_child)
---> 89 reduction.dump(process_obj, to_child)
90 finally:
91 set_spawning_popen(None)

~\AppData\Local\Continuum\anaconda3\lib\multiprocessing\reduction.py in dump(obj, file, protocol)
58 def dump(obj, file, protocol=None):
59 '''Replacement for pickle.dump() using ForkingPickler.'''
---> 60 ForkingPickler(file, protocol).dump(obj)
61
62 #

AttributeError: Can't pickle local object 'Dataset.load_data..TempClass'

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.