The results after each training keras model are different
I'm a newbie in Machine Learning. I want to build a keras model which will be used for facial recognition. I am currently using the model at:
model = Sequential()
model.add(Conv2D(32, (3, 3), padding='same',
input_shape=x_train.shape[1:]))
model.add(Activation('relu'))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same'))
model.add(Activation('relu'))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes))
model.add(Activation('softmax'))
# initiate RMSprop optimizer
opt = keras.optimizers.rmsprop(lr=0.0001, decay=1e-6)
# Let's train the model using RMSprop
model.compile(loss='categorical_crossentropy',
optimizer=opt,
metrics=['accuracy'])
I trained with the same data and parameters the same, but the training results are very different.There are 100% results or 28% results.
What made that difference?
python machine-learning keras
add a comment |
I'm a newbie in Machine Learning. I want to build a keras model which will be used for facial recognition. I am currently using the model at:
model = Sequential()
model.add(Conv2D(32, (3, 3), padding='same',
input_shape=x_train.shape[1:]))
model.add(Activation('relu'))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same'))
model.add(Activation('relu'))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes))
model.add(Activation('softmax'))
# initiate RMSprop optimizer
opt = keras.optimizers.rmsprop(lr=0.0001, decay=1e-6)
# Let's train the model using RMSprop
model.compile(loss='categorical_crossentropy',
optimizer=opt,
metrics=['accuracy'])
I trained with the same data and parameters the same, but the training results are very different.There are 100% results or 28% results.
What made that difference?
python machine-learning keras
1
Each training iteration would cause a weight update in the model. A change in weights would cause the model to perform differently which caused the difference in the training result.
– Edwin
Nov 13 '18 at 9:08
Thank for your suggestion @Edwin
– Pythoner
Nov 13 '18 at 9:18
1
The model is initialized with random weights at the beginning of training, so each time you train, you will arrive at a different local minima, producing different results. This is normal and not a programming problem.
– Matias Valdenegro
Nov 13 '18 at 10:09
add a comment |
I'm a newbie in Machine Learning. I want to build a keras model which will be used for facial recognition. I am currently using the model at:
model = Sequential()
model.add(Conv2D(32, (3, 3), padding='same',
input_shape=x_train.shape[1:]))
model.add(Activation('relu'))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same'))
model.add(Activation('relu'))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes))
model.add(Activation('softmax'))
# initiate RMSprop optimizer
opt = keras.optimizers.rmsprop(lr=0.0001, decay=1e-6)
# Let's train the model using RMSprop
model.compile(loss='categorical_crossentropy',
optimizer=opt,
metrics=['accuracy'])
I trained with the same data and parameters the same, but the training results are very different.There are 100% results or 28% results.
What made that difference?
python machine-learning keras
I'm a newbie in Machine Learning. I want to build a keras model which will be used for facial recognition. I am currently using the model at:
model = Sequential()
model.add(Conv2D(32, (3, 3), padding='same',
input_shape=x_train.shape[1:]))
model.add(Activation('relu'))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same'))
model.add(Activation('relu'))
model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes))
model.add(Activation('softmax'))
# initiate RMSprop optimizer
opt = keras.optimizers.rmsprop(lr=0.0001, decay=1e-6)
# Let's train the model using RMSprop
model.compile(loss='categorical_crossentropy',
optimizer=opt,
metrics=['accuracy'])
I trained with the same data and parameters the same, but the training results are very different.There are 100% results or 28% results.
What made that difference?
python machine-learning keras
python machine-learning keras
edited Nov 13 '18 at 9:13
Pythoner
asked Nov 13 '18 at 9:01
PythonerPythoner
228
228
1
Each training iteration would cause a weight update in the model. A change in weights would cause the model to perform differently which caused the difference in the training result.
– Edwin
Nov 13 '18 at 9:08
Thank for your suggestion @Edwin
– Pythoner
Nov 13 '18 at 9:18
1
The model is initialized with random weights at the beginning of training, so each time you train, you will arrive at a different local minima, producing different results. This is normal and not a programming problem.
– Matias Valdenegro
Nov 13 '18 at 10:09
add a comment |
1
Each training iteration would cause a weight update in the model. A change in weights would cause the model to perform differently which caused the difference in the training result.
– Edwin
Nov 13 '18 at 9:08
Thank for your suggestion @Edwin
– Pythoner
Nov 13 '18 at 9:18
1
The model is initialized with random weights at the beginning of training, so each time you train, you will arrive at a different local minima, producing different results. This is normal and not a programming problem.
– Matias Valdenegro
Nov 13 '18 at 10:09
1
1
Each training iteration would cause a weight update in the model. A change in weights would cause the model to perform differently which caused the difference in the training result.
– Edwin
Nov 13 '18 at 9:08
Each training iteration would cause a weight update in the model. A change in weights would cause the model to perform differently which caused the difference in the training result.
– Edwin
Nov 13 '18 at 9:08
Thank for your suggestion @Edwin
– Pythoner
Nov 13 '18 at 9:18
Thank for your suggestion @Edwin
– Pythoner
Nov 13 '18 at 9:18
1
1
The model is initialized with random weights at the beginning of training, so each time you train, you will arrive at a different local minima, producing different results. This is normal and not a programming problem.
– Matias Valdenegro
Nov 13 '18 at 10:09
The model is initialized with random weights at the beginning of training, so each time you train, you will arrive at a different local minima, producing different results. This is normal and not a programming problem.
– Matias Valdenegro
Nov 13 '18 at 10:09
add a comment |
1 Answer
1
active
oldest
votes
Setting the seed, when training the model will solve the problem. This will give you the repeatability.
np.random.seed(10)
tf.set_random_seed(10)
Also make sure train and test split also does not change ever instance. Hence, you can set the seed for data splitting also.
1
It seems my knowledge is too little about machine learning. Thanks for your suggesstion @AILearning
– Pythoner
Nov 13 '18 at 9:20
2
@Pythoner Welcome to SO; if the answer resolved your issue, kindly accept it (see What should I do when someone answers my question?).
– desertnaut
Nov 13 '18 at 9:23
If you do not mind, Can you recommend me a python and keras training model for applying face recognition to reality? The model I was looking for and tried unidentifiable use of my face and it always confused with other people in the data. My data is only three people –
– Pythoner
Nov 13 '18 at 9:26
@desertnaut I'm looking for related theories and try to fix them under suggestions. If this is the answer I will go back and confirm
– Pythoner
Nov 13 '18 at 9:27
1
pypi.org/project/face_recognition
– AI_Learning
Nov 13 '18 at 9:28
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fstackoverflow.com%2fquestions%2f53277246%2fthe-results-after-each-training-keras-model-are-different%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Setting the seed, when training the model will solve the problem. This will give you the repeatability.
np.random.seed(10)
tf.set_random_seed(10)
Also make sure train and test split also does not change ever instance. Hence, you can set the seed for data splitting also.
1
It seems my knowledge is too little about machine learning. Thanks for your suggesstion @AILearning
– Pythoner
Nov 13 '18 at 9:20
2
@Pythoner Welcome to SO; if the answer resolved your issue, kindly accept it (see What should I do when someone answers my question?).
– desertnaut
Nov 13 '18 at 9:23
If you do not mind, Can you recommend me a python and keras training model for applying face recognition to reality? The model I was looking for and tried unidentifiable use of my face and it always confused with other people in the data. My data is only three people –
– Pythoner
Nov 13 '18 at 9:26
@desertnaut I'm looking for related theories and try to fix them under suggestions. If this is the answer I will go back and confirm
– Pythoner
Nov 13 '18 at 9:27
1
pypi.org/project/face_recognition
– AI_Learning
Nov 13 '18 at 9:28
add a comment |
Setting the seed, when training the model will solve the problem. This will give you the repeatability.
np.random.seed(10)
tf.set_random_seed(10)
Also make sure train and test split also does not change ever instance. Hence, you can set the seed for data splitting also.
1
It seems my knowledge is too little about machine learning. Thanks for your suggesstion @AILearning
– Pythoner
Nov 13 '18 at 9:20
2
@Pythoner Welcome to SO; if the answer resolved your issue, kindly accept it (see What should I do when someone answers my question?).
– desertnaut
Nov 13 '18 at 9:23
If you do not mind, Can you recommend me a python and keras training model for applying face recognition to reality? The model I was looking for and tried unidentifiable use of my face and it always confused with other people in the data. My data is only three people –
– Pythoner
Nov 13 '18 at 9:26
@desertnaut I'm looking for related theories and try to fix them under suggestions. If this is the answer I will go back and confirm
– Pythoner
Nov 13 '18 at 9:27
1
pypi.org/project/face_recognition
– AI_Learning
Nov 13 '18 at 9:28
add a comment |
Setting the seed, when training the model will solve the problem. This will give you the repeatability.
np.random.seed(10)
tf.set_random_seed(10)
Also make sure train and test split also does not change ever instance. Hence, you can set the seed for data splitting also.
Setting the seed, when training the model will solve the problem. This will give you the repeatability.
np.random.seed(10)
tf.set_random_seed(10)
Also make sure train and test split also does not change ever instance. Hence, you can set the seed for data splitting also.
edited Nov 13 '18 at 9:22
desertnaut
17.1k63668
17.1k63668
answered Nov 13 '18 at 9:10
AI_LearningAI_Learning
3,3112933
3,3112933
1
It seems my knowledge is too little about machine learning. Thanks for your suggesstion @AILearning
– Pythoner
Nov 13 '18 at 9:20
2
@Pythoner Welcome to SO; if the answer resolved your issue, kindly accept it (see What should I do when someone answers my question?).
– desertnaut
Nov 13 '18 at 9:23
If you do not mind, Can you recommend me a python and keras training model for applying face recognition to reality? The model I was looking for and tried unidentifiable use of my face and it always confused with other people in the data. My data is only three people –
– Pythoner
Nov 13 '18 at 9:26
@desertnaut I'm looking for related theories and try to fix them under suggestions. If this is the answer I will go back and confirm
– Pythoner
Nov 13 '18 at 9:27
1
pypi.org/project/face_recognition
– AI_Learning
Nov 13 '18 at 9:28
add a comment |
1
It seems my knowledge is too little about machine learning. Thanks for your suggesstion @AILearning
– Pythoner
Nov 13 '18 at 9:20
2
@Pythoner Welcome to SO; if the answer resolved your issue, kindly accept it (see What should I do when someone answers my question?).
– desertnaut
Nov 13 '18 at 9:23
If you do not mind, Can you recommend me a python and keras training model for applying face recognition to reality? The model I was looking for and tried unidentifiable use of my face and it always confused with other people in the data. My data is only three people –
– Pythoner
Nov 13 '18 at 9:26
@desertnaut I'm looking for related theories and try to fix them under suggestions. If this is the answer I will go back and confirm
– Pythoner
Nov 13 '18 at 9:27
1
pypi.org/project/face_recognition
– AI_Learning
Nov 13 '18 at 9:28
1
1
It seems my knowledge is too little about machine learning. Thanks for your suggesstion @AILearning
– Pythoner
Nov 13 '18 at 9:20
It seems my knowledge is too little about machine learning. Thanks for your suggesstion @AILearning
– Pythoner
Nov 13 '18 at 9:20
2
2
@Pythoner Welcome to SO; if the answer resolved your issue, kindly accept it (see What should I do when someone answers my question?).
– desertnaut
Nov 13 '18 at 9:23
@Pythoner Welcome to SO; if the answer resolved your issue, kindly accept it (see What should I do when someone answers my question?).
– desertnaut
Nov 13 '18 at 9:23
If you do not mind, Can you recommend me a python and keras training model for applying face recognition to reality? The model I was looking for and tried unidentifiable use of my face and it always confused with other people in the data. My data is only three people –
– Pythoner
Nov 13 '18 at 9:26
If you do not mind, Can you recommend me a python and keras training model for applying face recognition to reality? The model I was looking for and tried unidentifiable use of my face and it always confused with other people in the data. My data is only three people –
– Pythoner
Nov 13 '18 at 9:26
@desertnaut I'm looking for related theories and try to fix them under suggestions. If this is the answer I will go back and confirm
– Pythoner
Nov 13 '18 at 9:27
@desertnaut I'm looking for related theories and try to fix them under suggestions. If this is the answer I will go back and confirm
– Pythoner
Nov 13 '18 at 9:27
1
1
pypi.org/project/face_recognition
– AI_Learning
Nov 13 '18 at 9:28
pypi.org/project/face_recognition
– AI_Learning
Nov 13 '18 at 9:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
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%2fstackoverflow.com%2fquestions%2f53277246%2fthe-results-after-each-training-keras-model-are-different%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
1
Each training iteration would cause a weight update in the model. A change in weights would cause the model to perform differently which caused the difference in the training result.
– Edwin
Nov 13 '18 at 9:08
Thank for your suggestion @Edwin
– Pythoner
Nov 13 '18 at 9:18
1
The model is initialized with random weights at the beginning of training, so each time you train, you will arrive at a different local minima, producing different results. This is normal and not a programming problem.
– Matias Valdenegro
Nov 13 '18 at 10:09