Best model type in TensorFlow.js for Color Prediction?
I was creating a color predictor when I realized a problem arise. I got the model to work successfully, but the predictions are always within the same median range of about 2.5 to about 5.5. The model is supposed to output a 0 thru 8 corresponding to each color, and I have an even amount of data point for each color for training. Is there a better model I can use so that it will predict something to be 0 or 7? I'm assuming it won't because it thinks they are some kind of outliers.
Here's my model
const model = tf.sequential();
const hidden = tf.layers.dense({
units: 3,
inputShape: [3] //Each input has 3 values r, g, and b
});
const output = tf.layers.dense({
units: 1 //only one output (the color that corresponds to the rgb values
});
model.add(hidden);
model.add(output);
model.compile({
activation: 'sigmoid',
loss: "meanSquaredError",
optimizer: tf.train.sgd(0.005)
});
Is this a good model for my problem?
javascript tensorflow machine-learning tensorflow.js
|
show 1 more comment
I was creating a color predictor when I realized a problem arise. I got the model to work successfully, but the predictions are always within the same median range of about 2.5 to about 5.5. The model is supposed to output a 0 thru 8 corresponding to each color, and I have an even amount of data point for each color for training. Is there a better model I can use so that it will predict something to be 0 or 7? I'm assuming it won't because it thinks they are some kind of outliers.
Here's my model
const model = tf.sequential();
const hidden = tf.layers.dense({
units: 3,
inputShape: [3] //Each input has 3 values r, g, and b
});
const output = tf.layers.dense({
units: 1 //only one output (the color that corresponds to the rgb values
});
model.add(hidden);
model.add(output);
model.compile({
activation: 'sigmoid',
loss: "meanSquaredError",
optimizer: tf.train.sgd(0.005)
});
Is this a good model for my problem?
javascript tensorflow machine-learning tensorflow.js
1
Welcome to SO; i kindly suggest to edit your question, remove the storytelling & the redundant info (it just creates clutter, lowering the chances of getting an answer), and clarify precisely and succinctly what exactly is your issue (as it stands, it's quite unclear). Be sure to read How do I ask a good question?
– desertnaut
Nov 21 '18 at 16:23
why don't you create a balanced dataset for each color? for example, 100 data points for each class. i think you are facing class imbalance issue.
– sjishan
Nov 21 '18 at 17:05
@sjishan I spent time to get 20 data points for every single color, and the problem still happens, still never leaves that median range, good suggestion tho, I would get to 100 on all data points but waiting to have some of the colors be randomly generated 100 times is pretty dang rare
– tanndlin
Nov 22 '18 at 13:23
@desertnaut Thanks for the tip! I tried to cut out the background information and only tried to keep mostly what will solve my problem
– tanndlin
Nov 22 '18 at 13:24
Does the output need to be an integer from the range 1 to 8? Because if that is the case, you're using regression for a classification problem. Also, you can add non-linearity to the model.
– edkeveked
Nov 23 '18 at 16:50
|
show 1 more comment
I was creating a color predictor when I realized a problem arise. I got the model to work successfully, but the predictions are always within the same median range of about 2.5 to about 5.5. The model is supposed to output a 0 thru 8 corresponding to each color, and I have an even amount of data point for each color for training. Is there a better model I can use so that it will predict something to be 0 or 7? I'm assuming it won't because it thinks they are some kind of outliers.
Here's my model
const model = tf.sequential();
const hidden = tf.layers.dense({
units: 3,
inputShape: [3] //Each input has 3 values r, g, and b
});
const output = tf.layers.dense({
units: 1 //only one output (the color that corresponds to the rgb values
});
model.add(hidden);
model.add(output);
model.compile({
activation: 'sigmoid',
loss: "meanSquaredError",
optimizer: tf.train.sgd(0.005)
});
Is this a good model for my problem?
javascript tensorflow machine-learning tensorflow.js
I was creating a color predictor when I realized a problem arise. I got the model to work successfully, but the predictions are always within the same median range of about 2.5 to about 5.5. The model is supposed to output a 0 thru 8 corresponding to each color, and I have an even amount of data point for each color for training. Is there a better model I can use so that it will predict something to be 0 or 7? I'm assuming it won't because it thinks they are some kind of outliers.
Here's my model
const model = tf.sequential();
const hidden = tf.layers.dense({
units: 3,
inputShape: [3] //Each input has 3 values r, g, and b
});
const output = tf.layers.dense({
units: 1 //only one output (the color that corresponds to the rgb values
});
model.add(hidden);
model.add(output);
model.compile({
activation: 'sigmoid',
loss: "meanSquaredError",
optimizer: tf.train.sgd(0.005)
});
Is this a good model for my problem?
javascript tensorflow machine-learning tensorflow.js
javascript tensorflow machine-learning tensorflow.js
edited Nov 23 '18 at 20:25
edkeveked
4,73331444
4,73331444
asked Nov 21 '18 at 16:14
tanndlintanndlin
104
104
1
Welcome to SO; i kindly suggest to edit your question, remove the storytelling & the redundant info (it just creates clutter, lowering the chances of getting an answer), and clarify precisely and succinctly what exactly is your issue (as it stands, it's quite unclear). Be sure to read How do I ask a good question?
– desertnaut
Nov 21 '18 at 16:23
why don't you create a balanced dataset for each color? for example, 100 data points for each class. i think you are facing class imbalance issue.
– sjishan
Nov 21 '18 at 17:05
@sjishan I spent time to get 20 data points for every single color, and the problem still happens, still never leaves that median range, good suggestion tho, I would get to 100 on all data points but waiting to have some of the colors be randomly generated 100 times is pretty dang rare
– tanndlin
Nov 22 '18 at 13:23
@desertnaut Thanks for the tip! I tried to cut out the background information and only tried to keep mostly what will solve my problem
– tanndlin
Nov 22 '18 at 13:24
Does the output need to be an integer from the range 1 to 8? Because if that is the case, you're using regression for a classification problem. Also, you can add non-linearity to the model.
– edkeveked
Nov 23 '18 at 16:50
|
show 1 more comment
1
Welcome to SO; i kindly suggest to edit your question, remove the storytelling & the redundant info (it just creates clutter, lowering the chances of getting an answer), and clarify precisely and succinctly what exactly is your issue (as it stands, it's quite unclear). Be sure to read How do I ask a good question?
– desertnaut
Nov 21 '18 at 16:23
why don't you create a balanced dataset for each color? for example, 100 data points for each class. i think you are facing class imbalance issue.
– sjishan
Nov 21 '18 at 17:05
@sjishan I spent time to get 20 data points for every single color, and the problem still happens, still never leaves that median range, good suggestion tho, I would get to 100 on all data points but waiting to have some of the colors be randomly generated 100 times is pretty dang rare
– tanndlin
Nov 22 '18 at 13:23
@desertnaut Thanks for the tip! I tried to cut out the background information and only tried to keep mostly what will solve my problem
– tanndlin
Nov 22 '18 at 13:24
Does the output need to be an integer from the range 1 to 8? Because if that is the case, you're using regression for a classification problem. Also, you can add non-linearity to the model.
– edkeveked
Nov 23 '18 at 16:50
1
1
Welcome to SO; i kindly suggest to edit your question, remove the storytelling & the redundant info (it just creates clutter, lowering the chances of getting an answer), and clarify precisely and succinctly what exactly is your issue (as it stands, it's quite unclear). Be sure to read How do I ask a good question?
– desertnaut
Nov 21 '18 at 16:23
Welcome to SO; i kindly suggest to edit your question, remove the storytelling & the redundant info (it just creates clutter, lowering the chances of getting an answer), and clarify precisely and succinctly what exactly is your issue (as it stands, it's quite unclear). Be sure to read How do I ask a good question?
– desertnaut
Nov 21 '18 at 16:23
why don't you create a balanced dataset for each color? for example, 100 data points for each class. i think you are facing class imbalance issue.
– sjishan
Nov 21 '18 at 17:05
why don't you create a balanced dataset for each color? for example, 100 data points for each class. i think you are facing class imbalance issue.
– sjishan
Nov 21 '18 at 17:05
@sjishan I spent time to get 20 data points for every single color, and the problem still happens, still never leaves that median range, good suggestion tho, I would get to 100 on all data points but waiting to have some of the colors be randomly generated 100 times is pretty dang rare
– tanndlin
Nov 22 '18 at 13:23
@sjishan I spent time to get 20 data points for every single color, and the problem still happens, still never leaves that median range, good suggestion tho, I would get to 100 on all data points but waiting to have some of the colors be randomly generated 100 times is pretty dang rare
– tanndlin
Nov 22 '18 at 13:23
@desertnaut Thanks for the tip! I tried to cut out the background information and only tried to keep mostly what will solve my problem
– tanndlin
Nov 22 '18 at 13:24
@desertnaut Thanks for the tip! I tried to cut out the background information and only tried to keep mostly what will solve my problem
– tanndlin
Nov 22 '18 at 13:24
Does the output need to be an integer from the range 1 to 8? Because if that is the case, you're using regression for a classification problem. Also, you can add non-linearity to the model.
– edkeveked
Nov 23 '18 at 16:50
Does the output need to be an integer from the range 1 to 8? Because if that is the case, you're using regression for a classification problem. Also, you can add non-linearity to the model.
– edkeveked
Nov 23 '18 at 16:50
|
show 1 more comment
1 Answer
1
active
oldest
votes
The model is lacking non-linearity, for there is no activation functions.
Given a rgb input, the model should predict the most likely color in 8 possible values. It is a classification problem. The model as defined in the question is doing a regression, i.e it is trying to predict a numerical value given the input.
For classification problem, the last layer should predict probabilities. softmax
activation function is mostly used for the last layer in that case.
The loss function should be categoricalCrossentropy
or binaryCrossEntropy
(if there were only two colors to predict).
Consider the following model predicting 3 classes of colors: red, green and blue
const model = tf.sequential();
model.add(tf.layers.dense({units: 10, inputShape: [3], activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 10, activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 3, activation: 'softmax' }));
model.compile({ loss: 'categoricalCrossentropy', optimizer: 'adam' });
const xs = tf.tensor([
[255, 23, 34],
[255, 23, 43],
[12, 255, 56],
[13, 255, 56],
[12, 23, 255],
[12, 56, 255]
]);
// Labels
const label = ['red', 'red', 'green', 'green', 'blue', 'blue']
const setLabel = Array.from(new Set(label))
const ys = tf.oneHot(tf.tensor1d(label.map((a) => setLabel.findIndex(e => e === a)), 'int32'), 3)
// Train the model using the data.
model.fit(xs, ys, {epochs: 100}).then((loss) => {
const t = model.predict(xs);
pred = t.argMax(1).dataSync(); // get the class of highest probability
labelsPred = Array.from(pred).map(e => setLabel[e])
console.log(labelsPred)
}).catch((e) => {
console.log(e.message);
})
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3/dist/tf.min.js"> </script>
</head>
<body>
</body>
</html>
Wow! Thanks! I see now, the idea is to get a probability for each color, then choose the highest probability, I understand now. But I have to ask, what lead you to made 2 hidden layers with 10 nodes?
– tanndlin
Nov 24 '18 at 2:29
For the number of layers and how many nodes for each layer, you can iterate until you find one that leads to better accuracy. There is no general formula for it.
– edkeveked
Nov 26 '18 at 18:42
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%2f53416245%2fbest-model-type-in-tensorflow-js-for-color-prediction%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
The model is lacking non-linearity, for there is no activation functions.
Given a rgb input, the model should predict the most likely color in 8 possible values. It is a classification problem. The model as defined in the question is doing a regression, i.e it is trying to predict a numerical value given the input.
For classification problem, the last layer should predict probabilities. softmax
activation function is mostly used for the last layer in that case.
The loss function should be categoricalCrossentropy
or binaryCrossEntropy
(if there were only two colors to predict).
Consider the following model predicting 3 classes of colors: red, green and blue
const model = tf.sequential();
model.add(tf.layers.dense({units: 10, inputShape: [3], activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 10, activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 3, activation: 'softmax' }));
model.compile({ loss: 'categoricalCrossentropy', optimizer: 'adam' });
const xs = tf.tensor([
[255, 23, 34],
[255, 23, 43],
[12, 255, 56],
[13, 255, 56],
[12, 23, 255],
[12, 56, 255]
]);
// Labels
const label = ['red', 'red', 'green', 'green', 'blue', 'blue']
const setLabel = Array.from(new Set(label))
const ys = tf.oneHot(tf.tensor1d(label.map((a) => setLabel.findIndex(e => e === a)), 'int32'), 3)
// Train the model using the data.
model.fit(xs, ys, {epochs: 100}).then((loss) => {
const t = model.predict(xs);
pred = t.argMax(1).dataSync(); // get the class of highest probability
labelsPred = Array.from(pred).map(e => setLabel[e])
console.log(labelsPred)
}).catch((e) => {
console.log(e.message);
})
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3/dist/tf.min.js"> </script>
</head>
<body>
</body>
</html>
Wow! Thanks! I see now, the idea is to get a probability for each color, then choose the highest probability, I understand now. But I have to ask, what lead you to made 2 hidden layers with 10 nodes?
– tanndlin
Nov 24 '18 at 2:29
For the number of layers and how many nodes for each layer, you can iterate until you find one that leads to better accuracy. There is no general formula for it.
– edkeveked
Nov 26 '18 at 18:42
add a comment |
The model is lacking non-linearity, for there is no activation functions.
Given a rgb input, the model should predict the most likely color in 8 possible values. It is a classification problem. The model as defined in the question is doing a regression, i.e it is trying to predict a numerical value given the input.
For classification problem, the last layer should predict probabilities. softmax
activation function is mostly used for the last layer in that case.
The loss function should be categoricalCrossentropy
or binaryCrossEntropy
(if there were only two colors to predict).
Consider the following model predicting 3 classes of colors: red, green and blue
const model = tf.sequential();
model.add(tf.layers.dense({units: 10, inputShape: [3], activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 10, activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 3, activation: 'softmax' }));
model.compile({ loss: 'categoricalCrossentropy', optimizer: 'adam' });
const xs = tf.tensor([
[255, 23, 34],
[255, 23, 43],
[12, 255, 56],
[13, 255, 56],
[12, 23, 255],
[12, 56, 255]
]);
// Labels
const label = ['red', 'red', 'green', 'green', 'blue', 'blue']
const setLabel = Array.from(new Set(label))
const ys = tf.oneHot(tf.tensor1d(label.map((a) => setLabel.findIndex(e => e === a)), 'int32'), 3)
// Train the model using the data.
model.fit(xs, ys, {epochs: 100}).then((loss) => {
const t = model.predict(xs);
pred = t.argMax(1).dataSync(); // get the class of highest probability
labelsPred = Array.from(pred).map(e => setLabel[e])
console.log(labelsPred)
}).catch((e) => {
console.log(e.message);
})
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3/dist/tf.min.js"> </script>
</head>
<body>
</body>
</html>
Wow! Thanks! I see now, the idea is to get a probability for each color, then choose the highest probability, I understand now. But I have to ask, what lead you to made 2 hidden layers with 10 nodes?
– tanndlin
Nov 24 '18 at 2:29
For the number of layers and how many nodes for each layer, you can iterate until you find one that leads to better accuracy. There is no general formula for it.
– edkeveked
Nov 26 '18 at 18:42
add a comment |
The model is lacking non-linearity, for there is no activation functions.
Given a rgb input, the model should predict the most likely color in 8 possible values. It is a classification problem. The model as defined in the question is doing a regression, i.e it is trying to predict a numerical value given the input.
For classification problem, the last layer should predict probabilities. softmax
activation function is mostly used for the last layer in that case.
The loss function should be categoricalCrossentropy
or binaryCrossEntropy
(if there were only two colors to predict).
Consider the following model predicting 3 classes of colors: red, green and blue
const model = tf.sequential();
model.add(tf.layers.dense({units: 10, inputShape: [3], activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 10, activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 3, activation: 'softmax' }));
model.compile({ loss: 'categoricalCrossentropy', optimizer: 'adam' });
const xs = tf.tensor([
[255, 23, 34],
[255, 23, 43],
[12, 255, 56],
[13, 255, 56],
[12, 23, 255],
[12, 56, 255]
]);
// Labels
const label = ['red', 'red', 'green', 'green', 'blue', 'blue']
const setLabel = Array.from(new Set(label))
const ys = tf.oneHot(tf.tensor1d(label.map((a) => setLabel.findIndex(e => e === a)), 'int32'), 3)
// Train the model using the data.
model.fit(xs, ys, {epochs: 100}).then((loss) => {
const t = model.predict(xs);
pred = t.argMax(1).dataSync(); // get the class of highest probability
labelsPred = Array.from(pred).map(e => setLabel[e])
console.log(labelsPred)
}).catch((e) => {
console.log(e.message);
})
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3/dist/tf.min.js"> </script>
</head>
<body>
</body>
</html>
The model is lacking non-linearity, for there is no activation functions.
Given a rgb input, the model should predict the most likely color in 8 possible values. It is a classification problem. The model as defined in the question is doing a regression, i.e it is trying to predict a numerical value given the input.
For classification problem, the last layer should predict probabilities. softmax
activation function is mostly used for the last layer in that case.
The loss function should be categoricalCrossentropy
or binaryCrossEntropy
(if there were only two colors to predict).
Consider the following model predicting 3 classes of colors: red, green and blue
const model = tf.sequential();
model.add(tf.layers.dense({units: 10, inputShape: [3], activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 10, activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 3, activation: 'softmax' }));
model.compile({ loss: 'categoricalCrossentropy', optimizer: 'adam' });
const xs = tf.tensor([
[255, 23, 34],
[255, 23, 43],
[12, 255, 56],
[13, 255, 56],
[12, 23, 255],
[12, 56, 255]
]);
// Labels
const label = ['red', 'red', 'green', 'green', 'blue', 'blue']
const setLabel = Array.from(new Set(label))
const ys = tf.oneHot(tf.tensor1d(label.map((a) => setLabel.findIndex(e => e === a)), 'int32'), 3)
// Train the model using the data.
model.fit(xs, ys, {epochs: 100}).then((loss) => {
const t = model.predict(xs);
pred = t.argMax(1).dataSync(); // get the class of highest probability
labelsPred = Array.from(pred).map(e => setLabel[e])
console.log(labelsPred)
}).catch((e) => {
console.log(e.message);
})
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3/dist/tf.min.js"> </script>
</head>
<body>
</body>
</html>
const model = tf.sequential();
model.add(tf.layers.dense({units: 10, inputShape: [3], activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 10, activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 3, activation: 'softmax' }));
model.compile({ loss: 'categoricalCrossentropy', optimizer: 'adam' });
const xs = tf.tensor([
[255, 23, 34],
[255, 23, 43],
[12, 255, 56],
[13, 255, 56],
[12, 23, 255],
[12, 56, 255]
]);
// Labels
const label = ['red', 'red', 'green', 'green', 'blue', 'blue']
const setLabel = Array.from(new Set(label))
const ys = tf.oneHot(tf.tensor1d(label.map((a) => setLabel.findIndex(e => e === a)), 'int32'), 3)
// Train the model using the data.
model.fit(xs, ys, {epochs: 100}).then((loss) => {
const t = model.predict(xs);
pred = t.argMax(1).dataSync(); // get the class of highest probability
labelsPred = Array.from(pred).map(e => setLabel[e])
console.log(labelsPred)
}).catch((e) => {
console.log(e.message);
})
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3/dist/tf.min.js"> </script>
</head>
<body>
</body>
</html>
const model = tf.sequential();
model.add(tf.layers.dense({units: 10, inputShape: [3], activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 10, activation: 'sigmoid' }));
model.add(tf.layers.dense({units: 3, activation: 'softmax' }));
model.compile({ loss: 'categoricalCrossentropy', optimizer: 'adam' });
const xs = tf.tensor([
[255, 23, 34],
[255, 23, 43],
[12, 255, 56],
[13, 255, 56],
[12, 23, 255],
[12, 56, 255]
]);
// Labels
const label = ['red', 'red', 'green', 'green', 'blue', 'blue']
const setLabel = Array.from(new Set(label))
const ys = tf.oneHot(tf.tensor1d(label.map((a) => setLabel.findIndex(e => e === a)), 'int32'), 3)
// Train the model using the data.
model.fit(xs, ys, {epochs: 100}).then((loss) => {
const t = model.predict(xs);
pred = t.argMax(1).dataSync(); // get the class of highest probability
labelsPred = Array.from(pred).map(e => setLabel[e])
console.log(labelsPred)
}).catch((e) => {
console.log(e.message);
})
<html>
<head>
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3/dist/tf.min.js"> </script>
</head>
<body>
</body>
</html>
edited Nov 23 '18 at 20:24
answered Nov 23 '18 at 16:43
edkevekededkeveked
4,73331444
4,73331444
Wow! Thanks! I see now, the idea is to get a probability for each color, then choose the highest probability, I understand now. But I have to ask, what lead you to made 2 hidden layers with 10 nodes?
– tanndlin
Nov 24 '18 at 2:29
For the number of layers and how many nodes for each layer, you can iterate until you find one that leads to better accuracy. There is no general formula for it.
– edkeveked
Nov 26 '18 at 18:42
add a comment |
Wow! Thanks! I see now, the idea is to get a probability for each color, then choose the highest probability, I understand now. But I have to ask, what lead you to made 2 hidden layers with 10 nodes?
– tanndlin
Nov 24 '18 at 2:29
For the number of layers and how many nodes for each layer, you can iterate until you find one that leads to better accuracy. There is no general formula for it.
– edkeveked
Nov 26 '18 at 18:42
Wow! Thanks! I see now, the idea is to get a probability for each color, then choose the highest probability, I understand now. But I have to ask, what lead you to made 2 hidden layers with 10 nodes?
– tanndlin
Nov 24 '18 at 2:29
Wow! Thanks! I see now, the idea is to get a probability for each color, then choose the highest probability, I understand now. But I have to ask, what lead you to made 2 hidden layers with 10 nodes?
– tanndlin
Nov 24 '18 at 2:29
For the number of layers and how many nodes for each layer, you can iterate until you find one that leads to better accuracy. There is no general formula for it.
– edkeveked
Nov 26 '18 at 18:42
For the number of layers and how many nodes for each layer, you can iterate until you find one that leads to better accuracy. There is no general formula for it.
– edkeveked
Nov 26 '18 at 18:42
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%2f53416245%2fbest-model-type-in-tensorflow-js-for-color-prediction%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
Welcome to SO; i kindly suggest to edit your question, remove the storytelling & the redundant info (it just creates clutter, lowering the chances of getting an answer), and clarify precisely and succinctly what exactly is your issue (as it stands, it's quite unclear). Be sure to read How do I ask a good question?
– desertnaut
Nov 21 '18 at 16:23
why don't you create a balanced dataset for each color? for example, 100 data points for each class. i think you are facing class imbalance issue.
– sjishan
Nov 21 '18 at 17:05
@sjishan I spent time to get 20 data points for every single color, and the problem still happens, still never leaves that median range, good suggestion tho, I would get to 100 on all data points but waiting to have some of the colors be randomly generated 100 times is pretty dang rare
– tanndlin
Nov 22 '18 at 13:23
@desertnaut Thanks for the tip! I tried to cut out the background information and only tried to keep mostly what will solve my problem
– tanndlin
Nov 22 '18 at 13:24
Does the output need to be an integer from the range 1 to 8? Because if that is the case, you're using regression for a classification problem. Also, you can add non-linearity to the model.
– edkeveked
Nov 23 '18 at 16:50