Grouping the Input Features for LSTM (keras)
$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,
- 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?
- If it is fine, why?
- 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.)
machine-learning neural-network keras lstm
New contributor
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$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,
- 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?
- If it is fine, why?
- 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.)
machine-learning neural-network keras lstm
New contributor
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
$begingroup$
You should try an implementation with both options (Flattened inputs + stacked LSTM and Convolutional LSTM).
$endgroup$
– Shamit Verma
yesterday
$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$
– seed.of.apricot
yesterday
$begingroup$
Quality of prediction + validation of the fact that model is able to learn relationship between inputs.
$endgroup$
– Shamit Verma
yesterday
$begingroup$
Understood, thank you for the clarification.
$endgroup$
– seed.of.apricot
yesterday
add a comment |
$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,
- 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?
- If it is fine, why?
- 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.)
machine-learning neural-network keras lstm
New contributor
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
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,
- 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?
- If it is fine, why?
- 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.)
machine-learning neural-network keras lstm
machine-learning neural-network keras lstm
New contributor
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked yesterday
seed.of.apricotseed.of.apricot
1111
1111
New contributor
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
seed.of.apricot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$begingroup$
You should try an implementation with both options (Flattened inputs + stacked LSTM and Convolutional LSTM).
$endgroup$
– Shamit Verma
yesterday
$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$
– seed.of.apricot
yesterday
$begingroup$
Quality of prediction + validation of the fact that model is able to learn relationship between inputs.
$endgroup$
– Shamit Verma
yesterday
$begingroup$
Understood, thank you for the clarification.
$endgroup$
– seed.of.apricot
yesterday
add a comment |
$begingroup$
You should try an implementation with both options (Flattened inputs + stacked LSTM and Convolutional LSTM).
$endgroup$
– Shamit Verma
yesterday
$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$
– seed.of.apricot
yesterday
$begingroup$
Quality of prediction + validation of the fact that model is able to learn relationship between inputs.
$endgroup$
– Shamit Verma
yesterday
$begingroup$
Understood, thank you for the clarification.
$endgroup$
– seed.of.apricot
yesterday
$begingroup$
You should try an implementation with both options (Flattened inputs + stacked LSTM and Convolutional LSTM).
$endgroup$
– Shamit Verma
yesterday
$begingroup$
You should try an implementation with both options (Flattened inputs + stacked LSTM and Convolutional LSTM).
$endgroup$
– Shamit Verma
yesterday
$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$
– seed.of.apricot
yesterday
$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$
– seed.of.apricot
yesterday
$begingroup$
Quality of prediction + validation of the fact that model is able to learn relationship between inputs.
$endgroup$
– Shamit Verma
yesterday
$begingroup$
Quality of prediction + validation of the fact that model is able to learn relationship between inputs.
$endgroup$
– Shamit Verma
yesterday
$begingroup$
Understood, thank you for the clarification.
$endgroup$
– seed.of.apricot
yesterday
$begingroup$
Understood, thank you for the clarification.
$endgroup$
– seed.of.apricot
yesterday
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "557"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
seed.of.apricot is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48851%2fgrouping-the-input-features-for-lstm-keras%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
seed.of.apricot is a new contributor. Be nice, and check out our Code of Conduct.
seed.of.apricot is a new contributor. Be nice, and check out our Code of Conduct.
seed.of.apricot is a new contributor. Be nice, and check out our Code of Conduct.
seed.of.apricot is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48851%2fgrouping-the-input-features-for-lstm-keras%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
You should try an implementation with both options (Flattened inputs + stacked LSTM and Convolutional LSTM).
$endgroup$
– Shamit Verma
yesterday
$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$
– seed.of.apricot
yesterday
$begingroup$
Quality of prediction + validation of the fact that model is able to learn relationship between inputs.
$endgroup$
– Shamit Verma
yesterday
$begingroup$
Understood, thank you for the clarification.
$endgroup$
– seed.of.apricot
yesterday