3
$\begingroup$

When I have a input feature of 2-dimension (variable*feature), is it still good to flatten them into 1-dimension input ({variable*feature}) in order to make a 3-dimensional input (sample,timestep,feature) for LSTM in keras?

Especially, wouldn't it cause a problem if the variables are considered as certain groups?

Assume I have 100 cities and 10 features (population, GDP, employment, living cost, ...) in each city, and then want to try predicting the population of one city. If I flatten the input feature, it would look like:

Time   POP1   GDP1   EMP1   LVC1  ...  POP2   GDP2   EMP2   LVC2  ... 
   1  10000   1000   2000   1500      15000   2000   3500   2000  ...
   2  12000   1200   1800   1600      16000   2100   3600   2100  ...
   3  13000   1300   1900   1700      18000   2200   3700   2250  ...
   ...

However, intrinsically, the features in the same category (POP1, POP2, ...) and in the same city (POP1, GDP1, EMP1, ...) will have a strong relationship than each others. Given this, it seems for me that flattering the input feature will lead to omit this implication from the model.

Then,

  1. Is it totally fine to flatter the input feature in this kind of prediction, where there is a group of features like a node in one graph network?
  2. If it is fine, why?
  3. If it is not, what would be a better way to represent this relationship between the cities? (I know Convolutional LSTM would be one solution, but it seems mainly for a larger 2-dimensional input such as images.)
$\endgroup$
4
  • 1
    $\begingroup$ You should try an implementation with both options (Flattened inputs + stacked LSTM and Convolutional LSTM). $\endgroup$ Apr 8 '19 at 8:41
  • $\begingroup$ Is that simply to see which is better in the prediction? Currently I'm using Flattered inputs + two-layers LSTM so I can try the other option so I can try the other. $\endgroup$
    – kemakino
    Apr 8 '19 at 8:59
  • $\begingroup$ Quality of prediction + validation of the fact that model is able to learn relationship between inputs. $\endgroup$ Apr 8 '19 at 9:26
  • $\begingroup$ Understood, thank you for the clarification. $\endgroup$
    – kemakino
    Apr 8 '19 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.