liulingbo918 / atfm Goto Github PK
View Code? Open in Web Editor NEWAttentive Traffic Flow Machines
License: MIT License
Attentive Traffic Flow Machines
License: MIT License
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?
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!
Hi
It seems that TaxiBJ could not download from the url
Can you please provide other ways to download this dataset?
Thanks a lot
i am not able to find data from link that you provide [data is remove ] ( from where can find data Taxibj and bikeNyc)
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
Hi,
I was seeing if the authors of this work would add a license to the software so that others may distribute and use the existing code base?
A link to an MIT License can be found here https://choosealicense.com/licenses/mit/#suggest-this-license, most researchers add a License.txt file to the main directory such as , https://github.com/FGiuliari/Trajectory-Transformer.
Thank you,
JP
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!
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?
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
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.