Binary Classification of Numeric Sequences with Keras and LSTMs2019 Community Moderator ElectionLSTM neural network for music generationDot Product between two Keras intermediate variablesWhy does my model accuracy rise and then drop, with the loss sharing similar characteristics?Best model for Machine LearningKeras LSTM model for binary classification with sequencesHow to set input for proper fit with lstm?Neural network outputting same result for all inputsPython - Predicting data based on multidimensional array with KerasHow to reshape data for LSTM training in multivariate sequence predictionIN CIFAR 10 DATASET
How is it possible to have an ability score that is less than 3?
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
How does strength of boric acid solution increase in presence of salicylic acid?
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
Why Is Death Allowed In the Matrix?
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
Why, historically, did Gödel think CH was false?
What's the point of deactivating Num Lock on login screens?
Can divisibility rules for digits be generalized to sum of digits
Today is the Center
Pattern match does not work in bash script
TGV timetables / schedules?
Can a Warlock become Neutral Good?
To string or not to string
What would happen to a modern skyscraper if it rains micro blackholes?
Can I ask the recruiters in my resume to put the reason why I am rejected?
Watching something be written to a file live with tail
What do three bars across the stem of a note mean?
Can I make popcorn with any corn?
LaTeX closing $ signs makes cursor jump
Why don't electron-positron collisions release infinite energy?
Is a conference paper whose proceedings will be published in IEEE Xplore counted as a publication?
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
Binary Classification of Numeric Sequences with Keras and LSTMs
2019 Community Moderator ElectionLSTM neural network for music generationDot Product between two Keras intermediate variablesWhy does my model accuracy rise and then drop, with the loss sharing similar characteristics?Best model for Machine LearningKeras LSTM model for binary classification with sequencesHow to set input for proper fit with lstm?Neural network outputting same result for all inputsPython - Predicting data based on multidimensional array with KerasHow to reshape data for LSTM training in multivariate sequence predictionIN CIFAR 10 DATASET
$begingroup$
I'm attempting to use a sequence of numbers (of fixed length) in order to predict a binary output (either 1 or 0) using Keras and a recurrent neural network.
Each training example/sequence has 10 timesteps, each containing a vector of 5 numbers, and each training output consists of either a 1 or 0. There are around 100,000 training examples.
I have tried implementing this using Keras, but the loss stops decreasing after the first epoch of training. I've also attempted modifying the hyper-parameters, but to no avail. Is there something I'm missing here?
The training inputs are as follows: (zero padded)
array([[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24829336, 0.96461449, 3.35142857, 0.74675 , 0.776075 ],
[1.248303 , 0.96427925, 0. , 1.317225 , 1.317225 ],
[1.24831488, 0.96409169, 2.74857143, 1.353775 , 1.377825 ]],
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24969672, 0.96336315, 0. , 1.319725 , 1.319725 ],
[1.24968077, 0.96331624, 0. , 1.33535 , 1.33535 ],
[1.24969598, 0.96330252, 5.01714286, 1.3508 , 1.3947 ]],
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[0. , 0. , 0. , 0. , 0. ],
[1.25715364, 0.95520672, 2.57714286, 1.04565 , 1.0682 ],
[1.25291274, 0.96879701, 7.76 , 1.311875 , 1.379775 ]],
...,
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24791079, 0.96561021, 4.44 , 0.7199 , 0.75875 ],
[1.25265263, 0.96117379, 2.09714286, 0.7636 , 0.78195 ],
[1.25868651, 0.96001674, 3.01142857, 1.35235 , 1.3787 ]]])
The training outputs are as follows:
array([[0.],
[0.],
[0.],
...,
[1.],
[0.],
[0.]])
This is the model I have attempted to train:
#Model
model = Sequential()
model.add(LSTM(100, input_shape= (10, 5)))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
print(model.summary())
model.fit(X_train, y_train, validation_data = (X_test, y_test), epochs = 100, batch_size = 1000)
classification keras lstm binary neural
New contributor
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
|
show 3 more comments
$begingroup$
I'm attempting to use a sequence of numbers (of fixed length) in order to predict a binary output (either 1 or 0) using Keras and a recurrent neural network.
Each training example/sequence has 10 timesteps, each containing a vector of 5 numbers, and each training output consists of either a 1 or 0. There are around 100,000 training examples.
I have tried implementing this using Keras, but the loss stops decreasing after the first epoch of training. I've also attempted modifying the hyper-parameters, but to no avail. Is there something I'm missing here?
The training inputs are as follows: (zero padded)
array([[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24829336, 0.96461449, 3.35142857, 0.74675 , 0.776075 ],
[1.248303 , 0.96427925, 0. , 1.317225 , 1.317225 ],
[1.24831488, 0.96409169, 2.74857143, 1.353775 , 1.377825 ]],
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24969672, 0.96336315, 0. , 1.319725 , 1.319725 ],
[1.24968077, 0.96331624, 0. , 1.33535 , 1.33535 ],
[1.24969598, 0.96330252, 5.01714286, 1.3508 , 1.3947 ]],
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[0. , 0. , 0. , 0. , 0. ],
[1.25715364, 0.95520672, 2.57714286, 1.04565 , 1.0682 ],
[1.25291274, 0.96879701, 7.76 , 1.311875 , 1.379775 ]],
...,
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24791079, 0.96561021, 4.44 , 0.7199 , 0.75875 ],
[1.25265263, 0.96117379, 2.09714286, 0.7636 , 0.78195 ],
[1.25868651, 0.96001674, 3.01142857, 1.35235 , 1.3787 ]]])
The training outputs are as follows:
array([[0.],
[0.],
[0.],
...,
[1.],
[0.],
[0.]])
This is the model I have attempted to train:
#Model
model = Sequential()
model.add(LSTM(100, input_shape= (10, 5)))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
print(model.summary())
model.fit(X_train, y_train, validation_data = (X_test, y_test), epochs = 100, batch_size = 1000)
classification keras lstm binary neural
New contributor
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
$begingroup$
How many training instances do you have?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
I have around 100,000 instances
$endgroup$
– George Lee
5 hours ago
1
$begingroup$
Welcome to SE.DataScience! Please provide these two: (1) ratio of 1s to all instances, and (2) value of loss for first, second, and third epochs. I may have an answer.
$endgroup$
– Esmailian
5 hours ago
1
$begingroup$
Can you give us a snippet of the data please?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
(1) 1:4 (2) Loss actually flattens out after around 3-4 epochs, at around 0.5870, 0.5805, 0.5804
$endgroup$
– George Lee
4 hours ago
|
show 3 more comments
$begingroup$
I'm attempting to use a sequence of numbers (of fixed length) in order to predict a binary output (either 1 or 0) using Keras and a recurrent neural network.
Each training example/sequence has 10 timesteps, each containing a vector of 5 numbers, and each training output consists of either a 1 or 0. There are around 100,000 training examples.
I have tried implementing this using Keras, but the loss stops decreasing after the first epoch of training. I've also attempted modifying the hyper-parameters, but to no avail. Is there something I'm missing here?
The training inputs are as follows: (zero padded)
array([[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24829336, 0.96461449, 3.35142857, 0.74675 , 0.776075 ],
[1.248303 , 0.96427925, 0. , 1.317225 , 1.317225 ],
[1.24831488, 0.96409169, 2.74857143, 1.353775 , 1.377825 ]],
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24969672, 0.96336315, 0. , 1.319725 , 1.319725 ],
[1.24968077, 0.96331624, 0. , 1.33535 , 1.33535 ],
[1.24969598, 0.96330252, 5.01714286, 1.3508 , 1.3947 ]],
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[0. , 0. , 0. , 0. , 0. ],
[1.25715364, 0.95520672, 2.57714286, 1.04565 , 1.0682 ],
[1.25291274, 0.96879701, 7.76 , 1.311875 , 1.379775 ]],
...,
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24791079, 0.96561021, 4.44 , 0.7199 , 0.75875 ],
[1.25265263, 0.96117379, 2.09714286, 0.7636 , 0.78195 ],
[1.25868651, 0.96001674, 3.01142857, 1.35235 , 1.3787 ]]])
The training outputs are as follows:
array([[0.],
[0.],
[0.],
...,
[1.],
[0.],
[0.]])
This is the model I have attempted to train:
#Model
model = Sequential()
model.add(LSTM(100, input_shape= (10, 5)))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
print(model.summary())
model.fit(X_train, y_train, validation_data = (X_test, y_test), epochs = 100, batch_size = 1000)
classification keras lstm binary neural
New contributor
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
I'm attempting to use a sequence of numbers (of fixed length) in order to predict a binary output (either 1 or 0) using Keras and a recurrent neural network.
Each training example/sequence has 10 timesteps, each containing a vector of 5 numbers, and each training output consists of either a 1 or 0. There are around 100,000 training examples.
I have tried implementing this using Keras, but the loss stops decreasing after the first epoch of training. I've also attempted modifying the hyper-parameters, but to no avail. Is there something I'm missing here?
The training inputs are as follows: (zero padded)
array([[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24829336, 0.96461449, 3.35142857, 0.74675 , 0.776075 ],
[1.248303 , 0.96427925, 0. , 1.317225 , 1.317225 ],
[1.24831488, 0.96409169, 2.74857143, 1.353775 , 1.377825 ]],
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24969672, 0.96336315, 0. , 1.319725 , 1.319725 ],
[1.24968077, 0.96331624, 0. , 1.33535 , 1.33535 ],
[1.24969598, 0.96330252, 5.01714286, 1.3508 , 1.3947 ]],
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[0. , 0. , 0. , 0. , 0. ],
[1.25715364, 0.95520672, 2.57714286, 1.04565 , 1.0682 ],
[1.25291274, 0.96879701, 7.76 , 1.311875 , 1.379775 ]],
...,
[[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ],
...,
[1.24791079, 0.96561021, 4.44 , 0.7199 , 0.75875 ],
[1.25265263, 0.96117379, 2.09714286, 0.7636 , 0.78195 ],
[1.25868651, 0.96001674, 3.01142857, 1.35235 , 1.3787 ]]])
The training outputs are as follows:
array([[0.],
[0.],
[0.],
...,
[1.],
[0.],
[0.]])
This is the model I have attempted to train:
#Model
model = Sequential()
model.add(LSTM(100, input_shape= (10, 5)))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
print(model.summary())
model.fit(X_train, y_train, validation_data = (X_test, y_test), epochs = 100, batch_size = 1000)
classification keras lstm binary neural
classification keras lstm binary neural
New contributor
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 4 hours ago
George Lee
New contributor
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 5 hours ago
George LeeGeorge Lee
11
11
New contributor
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
George Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$begingroup$
How many training instances do you have?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
I have around 100,000 instances
$endgroup$
– George Lee
5 hours ago
1
$begingroup$
Welcome to SE.DataScience! Please provide these two: (1) ratio of 1s to all instances, and (2) value of loss for first, second, and third epochs. I may have an answer.
$endgroup$
– Esmailian
5 hours ago
1
$begingroup$
Can you give us a snippet of the data please?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
(1) 1:4 (2) Loss actually flattens out after around 3-4 epochs, at around 0.5870, 0.5805, 0.5804
$endgroup$
– George Lee
4 hours ago
|
show 3 more comments
$begingroup$
How many training instances do you have?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
I have around 100,000 instances
$endgroup$
– George Lee
5 hours ago
1
$begingroup$
Welcome to SE.DataScience! Please provide these two: (1) ratio of 1s to all instances, and (2) value of loss for first, second, and third epochs. I may have an answer.
$endgroup$
– Esmailian
5 hours ago
1
$begingroup$
Can you give us a snippet of the data please?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
(1) 1:4 (2) Loss actually flattens out after around 3-4 epochs, at around 0.5870, 0.5805, 0.5804
$endgroup$
– George Lee
4 hours ago
$begingroup$
How many training instances do you have?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
How many training instances do you have?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
I have around 100,000 instances
$endgroup$
– George Lee
5 hours ago
$begingroup$
I have around 100,000 instances
$endgroup$
– George Lee
5 hours ago
1
1
$begingroup$
Welcome to SE.DataScience! Please provide these two: (1) ratio of 1s to all instances, and (2) value of loss for first, second, and third epochs. I may have an answer.
$endgroup$
– Esmailian
5 hours ago
$begingroup$
Welcome to SE.DataScience! Please provide these two: (1) ratio of 1s to all instances, and (2) value of loss for first, second, and third epochs. I may have an answer.
$endgroup$
– Esmailian
5 hours ago
1
1
$begingroup$
Can you give us a snippet of the data please?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
Can you give us a snippet of the data please?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
(1) 1:4 (2) Loss actually flattens out after around 3-4 epochs, at around 0.5870, 0.5805, 0.5804
$endgroup$
– George Lee
4 hours ago
$begingroup$
(1) 1:4 (2) Loss actually flattens out after around 3-4 epochs, at around 0.5870, 0.5805, 0.5804
$endgroup$
– George Lee
4 hours ago
|
show 3 more comments
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
);
);
George Lee 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%2f48764%2fbinary-classification-of-numeric-sequences-with-keras-and-lstms%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
George Lee is a new contributor. Be nice, and check out our Code of Conduct.
George Lee is a new contributor. Be nice, and check out our Code of Conduct.
George Lee is a new contributor. Be nice, and check out our Code of Conduct.
George Lee 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%2f48764%2fbinary-classification-of-numeric-sequences-with-keras-and-lstms%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$
How many training instances do you have?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
I have around 100,000 instances
$endgroup$
– George Lee
5 hours ago
1
$begingroup$
Welcome to SE.DataScience! Please provide these two: (1) ratio of 1s to all instances, and (2) value of loss for first, second, and third epochs. I may have an answer.
$endgroup$
– Esmailian
5 hours ago
1
$begingroup$
Can you give us a snippet of the data please?
$endgroup$
– JahKnows
5 hours ago
$begingroup$
(1) 1:4 (2) Loss actually flattens out after around 3-4 epochs, at around 0.5870, 0.5805, 0.5804
$endgroup$
– George Lee
4 hours ago