How to shift output of predict values into the x1 (input) column 0 values using Neural network in python
$begingroup$
The inputs here are the 3. The output here (LSTM) is the probabilities that the next x1 input ought to be.
Means here I have x,x1,x2 input values. 1st three inputs LSTM output1 and then next if x value = 0 then Lstm output1 is back into as input and predict next output2. If this output 2 value is equal to next x value then back into as input and predict output 3. If not equal not to take output 2 as x input and take it as mentioned x input. The output (Yt) at timestep t depends on the input X(t) and on the previous output Y(t-1).
as a example
x x1 x2 predict (output)
60 0 30 260
0 20 0 130
110 10 0 160
0 0 10 100
here second value of x1 column is 0, x value = 0 then take the value as output 1
x = output1
here x column 3rd value measured and output 2 value is not equal to x 3rd value.
then take input as measured value.
So this is the method that I want to do. But I don't know how to write it. Can anyone helps me to do it?
my LSTM code:
fit1 = Sequential ()
fit1.add(LSTM(32, return_sequences=True, activation='relu',input_shape=(3,1)))
fit1.add((LSTM(32, return_sequences=True)))
fit1.add(LSTM(32))
fit1.add(Dense(1))
batchsize = 3
fit1.compile(loss="mean_squared_error",optimizer="adam")
fit1.fit(x_train , y_train , batch_size = batchsize, nb_epoch =10,shuffle=True)
pred1=fit1.predict(x_test)
for i in range(len(x)):
pred1.append(fit1.predict([x[i,None,:],pred1[i]]))
pred1 = np.asarray(pred1)
pred1 = pred1.reshape(pred1.shape[0],pred1.shape[2])
But this is not working. not having relationship inbetween input and output.
error:
python neural-network keras tensorflow lstm
$endgroup$
add a comment |
$begingroup$
The inputs here are the 3. The output here (LSTM) is the probabilities that the next x1 input ought to be.
Means here I have x,x1,x2 input values. 1st three inputs LSTM output1 and then next if x value = 0 then Lstm output1 is back into as input and predict next output2. If this output 2 value is equal to next x value then back into as input and predict output 3. If not equal not to take output 2 as x input and take it as mentioned x input. The output (Yt) at timestep t depends on the input X(t) and on the previous output Y(t-1).
as a example
x x1 x2 predict (output)
60 0 30 260
0 20 0 130
110 10 0 160
0 0 10 100
here second value of x1 column is 0, x value = 0 then take the value as output 1
x = output1
here x column 3rd value measured and output 2 value is not equal to x 3rd value.
then take input as measured value.
So this is the method that I want to do. But I don't know how to write it. Can anyone helps me to do it?
my LSTM code:
fit1 = Sequential ()
fit1.add(LSTM(32, return_sequences=True, activation='relu',input_shape=(3,1)))
fit1.add((LSTM(32, return_sequences=True)))
fit1.add(LSTM(32))
fit1.add(Dense(1))
batchsize = 3
fit1.compile(loss="mean_squared_error",optimizer="adam")
fit1.fit(x_train , y_train , batch_size = batchsize, nb_epoch =10,shuffle=True)
pred1=fit1.predict(x_test)
for i in range(len(x)):
pred1.append(fit1.predict([x[i,None,:],pred1[i]]))
pred1 = np.asarray(pred1)
pred1 = pred1.reshape(pred1.shape[0],pred1.shape[2])
But this is not working. not having relationship inbetween input and output.
error:
python neural-network keras tensorflow lstm
$endgroup$
add a comment |
$begingroup$
The inputs here are the 3. The output here (LSTM) is the probabilities that the next x1 input ought to be.
Means here I have x,x1,x2 input values. 1st three inputs LSTM output1 and then next if x value = 0 then Lstm output1 is back into as input and predict next output2. If this output 2 value is equal to next x value then back into as input and predict output 3. If not equal not to take output 2 as x input and take it as mentioned x input. The output (Yt) at timestep t depends on the input X(t) and on the previous output Y(t-1).
as a example
x x1 x2 predict (output)
60 0 30 260
0 20 0 130
110 10 0 160
0 0 10 100
here second value of x1 column is 0, x value = 0 then take the value as output 1
x = output1
here x column 3rd value measured and output 2 value is not equal to x 3rd value.
then take input as measured value.
So this is the method that I want to do. But I don't know how to write it. Can anyone helps me to do it?
my LSTM code:
fit1 = Sequential ()
fit1.add(LSTM(32, return_sequences=True, activation='relu',input_shape=(3,1)))
fit1.add((LSTM(32, return_sequences=True)))
fit1.add(LSTM(32))
fit1.add(Dense(1))
batchsize = 3
fit1.compile(loss="mean_squared_error",optimizer="adam")
fit1.fit(x_train , y_train , batch_size = batchsize, nb_epoch =10,shuffle=True)
pred1=fit1.predict(x_test)
for i in range(len(x)):
pred1.append(fit1.predict([x[i,None,:],pred1[i]]))
pred1 = np.asarray(pred1)
pred1 = pred1.reshape(pred1.shape[0],pred1.shape[2])
But this is not working. not having relationship inbetween input and output.
error:
python neural-network keras tensorflow lstm
$endgroup$
The inputs here are the 3. The output here (LSTM) is the probabilities that the next x1 input ought to be.
Means here I have x,x1,x2 input values. 1st three inputs LSTM output1 and then next if x value = 0 then Lstm output1 is back into as input and predict next output2. If this output 2 value is equal to next x value then back into as input and predict output 3. If not equal not to take output 2 as x input and take it as mentioned x input. The output (Yt) at timestep t depends on the input X(t) and on the previous output Y(t-1).
as a example
x x1 x2 predict (output)
60 0 30 260
0 20 0 130
110 10 0 160
0 0 10 100
here second value of x1 column is 0, x value = 0 then take the value as output 1
x = output1
here x column 3rd value measured and output 2 value is not equal to x 3rd value.
then take input as measured value.
So this is the method that I want to do. But I don't know how to write it. Can anyone helps me to do it?
my LSTM code:
fit1 = Sequential ()
fit1.add(LSTM(32, return_sequences=True, activation='relu',input_shape=(3,1)))
fit1.add((LSTM(32, return_sequences=True)))
fit1.add(LSTM(32))
fit1.add(Dense(1))
batchsize = 3
fit1.compile(loss="mean_squared_error",optimizer="adam")
fit1.fit(x_train , y_train , batch_size = batchsize, nb_epoch =10,shuffle=True)
pred1=fit1.predict(x_test)
for i in range(len(x)):
pred1.append(fit1.predict([x[i,None,:],pred1[i]]))
pred1 = np.asarray(pred1)
pred1 = pred1.reshape(pred1.shape[0],pred1.shape[2])
But this is not working. not having relationship inbetween input and output.
error:
python neural-network keras tensorflow lstm
python neural-network keras tensorflow lstm
asked 4 mins ago
kaskas
617
617
add a comment |
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
});
}
});
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%2f45478%2fhow-to-shift-output-of-predict-values-into-the-x1-input-column-0-values-using%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
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%2f45478%2fhow-to-shift-output-of-predict-values-into-the-x1-input-column-0-values-using%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