Keras Fit Function (R): Train Regression Model with multiple Labels Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsHow to calculate accuracy on keras model with multiple outputs?Can I use fit() function with images in Keras?Validation-split of Keras fit functionKeras - Error when using HDF5Matrix to fit the modeltraining when Multiple labels per imageValue of loss and accuracy does not change over EpochsMultiple-input multiple-output CNN with custom loss functionMxnet model load with keras?IN CIFAR 10 DATASETKeras + Tensorflow CNN with multiple image inputs
How do I stop a creek from eroding my steep embankment?
Is there any avatar supposed to be born between the death of Krishna and the birth of Kalki?
What is a Meta algorithm?
Output the ŋarâþ crîþ alphabet song without using (m)any letters
How do I keep my slimes from escaping their pens?
Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?
Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?
Does surprise arrest existing movement?
Why is "Captain Marvel" translated as male in Portugal?
"Seemed to had" is it correct?
What do you call a plan that's an alternative plan in case your initial plan fails?
How to bypass password on Windows XP account?
How to motivate offshore teams and trust them to deliver?
Is there a concise way to say "all of the X, one of each"?
Dominant seventh chord in the major scale contains diminished triad of the seventh?
How can I fade player character when he goes inside or outside of the area?
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
Stars Make Stars
How to deal with a team lead who never gives me credit?
Super Attribute Position on Product Page Magento 1
What is this single-engine low-wing propeller plane?
Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?
How can players work together to take actions that are otherwise impossible?
Why is "Consequences inflicted." not a sentence?
Keras Fit Function (R): Train Regression Model with multiple Labels
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsHow to calculate accuracy on keras model with multiple outputs?Can I use fit() function with images in Keras?Validation-split of Keras fit functionKeras - Error when using HDF5Matrix to fit the modeltraining when Multiple labels per imageValue of loss and accuracy does not change over EpochsMultiple-input multiple-output CNN with custom loss functionMxnet model load with keras?IN CIFAR 10 DATASETKeras + Tensorflow CNN with multiple image inputs
$begingroup$
I am trying to implement a deep learning model in R using Keras. Let's say I had a dataset of people's faces and a CSV with information about the person's age, gender, and ethnicity. I want to train the model to predict a person's age from their photo.
For this, I have to use convolutional neural networks. Here is my pseudocode:
library(keras)
model <- keras_model_sequential()
model %>% ## define CNN model’s architecture.
## I will figure this out later
# configure model
model %>% compile(
loss='mean_squared_error',
optimizer='adam',
metrics='mae'
)
history <- model %>% fit(
# train_array is a 300x100x100x1 array
# train_array stores the pixel values of 300 grayscale images
# of resolution 100x100
x = train_array, y = ???,
epochs = 10, batch_size = 30,
)
My question is regarding the ???
marked above. I have three pieces of useful information to train the model: age
, gender
, and ethnicity
. How do I add this information to the model? Again, I want the model to predict a single prediction of age.
I looked at the Keras fit function documentation but couldn't figure it out. It says that y
is a "Vector, matrix, or array of target (label) data (or list if the model has multiple outputs)..."
EDIT:
That makes sense. Now the question is how do I set up the x
list? Here's what I have so far:
trainFeatures <- list(pixels = train_array, gender = as.factor(trainGenders), ethnicity = as.factor(trainEthnicity))
history <- model %>% fit(
x = trainFeatures, y = trainAge,
epochs = 10, batch_size = 30,
)
I downloaded a toy dataset and set up a quick CNN model. I got the following error message:
Error in py_get_attr_impl(x, name, silent) :
AttributeError: 'list' object has no attribute 'dtype'
r keras cnn
$endgroup$
bumped to the homepage by Community♦ 43 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
$begingroup$
I am trying to implement a deep learning model in R using Keras. Let's say I had a dataset of people's faces and a CSV with information about the person's age, gender, and ethnicity. I want to train the model to predict a person's age from their photo.
For this, I have to use convolutional neural networks. Here is my pseudocode:
library(keras)
model <- keras_model_sequential()
model %>% ## define CNN model’s architecture.
## I will figure this out later
# configure model
model %>% compile(
loss='mean_squared_error',
optimizer='adam',
metrics='mae'
)
history <- model %>% fit(
# train_array is a 300x100x100x1 array
# train_array stores the pixel values of 300 grayscale images
# of resolution 100x100
x = train_array, y = ???,
epochs = 10, batch_size = 30,
)
My question is regarding the ???
marked above. I have three pieces of useful information to train the model: age
, gender
, and ethnicity
. How do I add this information to the model? Again, I want the model to predict a single prediction of age.
I looked at the Keras fit function documentation but couldn't figure it out. It says that y
is a "Vector, matrix, or array of target (label) data (or list if the model has multiple outputs)..."
EDIT:
That makes sense. Now the question is how do I set up the x
list? Here's what I have so far:
trainFeatures <- list(pixels = train_array, gender = as.factor(trainGenders), ethnicity = as.factor(trainEthnicity))
history <- model %>% fit(
x = trainFeatures, y = trainAge,
epochs = 10, batch_size = 30,
)
I downloaded a toy dataset and set up a quick CNN model. I got the following error message:
Error in py_get_attr_impl(x, name, silent) :
AttributeError: 'list' object has no attribute 'dtype'
r keras cnn
$endgroup$
bumped to the homepage by Community♦ 43 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
$begingroup$
I had the same error. I fixed it by transforming y to numeric type, it was factor and this raised the error.
$endgroup$
– kamelst
Mar 15 at 22:07
add a comment |
$begingroup$
I am trying to implement a deep learning model in R using Keras. Let's say I had a dataset of people's faces and a CSV with information about the person's age, gender, and ethnicity. I want to train the model to predict a person's age from their photo.
For this, I have to use convolutional neural networks. Here is my pseudocode:
library(keras)
model <- keras_model_sequential()
model %>% ## define CNN model’s architecture.
## I will figure this out later
# configure model
model %>% compile(
loss='mean_squared_error',
optimizer='adam',
metrics='mae'
)
history <- model %>% fit(
# train_array is a 300x100x100x1 array
# train_array stores the pixel values of 300 grayscale images
# of resolution 100x100
x = train_array, y = ???,
epochs = 10, batch_size = 30,
)
My question is regarding the ???
marked above. I have three pieces of useful information to train the model: age
, gender
, and ethnicity
. How do I add this information to the model? Again, I want the model to predict a single prediction of age.
I looked at the Keras fit function documentation but couldn't figure it out. It says that y
is a "Vector, matrix, or array of target (label) data (or list if the model has multiple outputs)..."
EDIT:
That makes sense. Now the question is how do I set up the x
list? Here's what I have so far:
trainFeatures <- list(pixels = train_array, gender = as.factor(trainGenders), ethnicity = as.factor(trainEthnicity))
history <- model %>% fit(
x = trainFeatures, y = trainAge,
epochs = 10, batch_size = 30,
)
I downloaded a toy dataset and set up a quick CNN model. I got the following error message:
Error in py_get_attr_impl(x, name, silent) :
AttributeError: 'list' object has no attribute 'dtype'
r keras cnn
$endgroup$
I am trying to implement a deep learning model in R using Keras. Let's say I had a dataset of people's faces and a CSV with information about the person's age, gender, and ethnicity. I want to train the model to predict a person's age from their photo.
For this, I have to use convolutional neural networks. Here is my pseudocode:
library(keras)
model <- keras_model_sequential()
model %>% ## define CNN model’s architecture.
## I will figure this out later
# configure model
model %>% compile(
loss='mean_squared_error',
optimizer='adam',
metrics='mae'
)
history <- model %>% fit(
# train_array is a 300x100x100x1 array
# train_array stores the pixel values of 300 grayscale images
# of resolution 100x100
x = train_array, y = ???,
epochs = 10, batch_size = 30,
)
My question is regarding the ???
marked above. I have three pieces of useful information to train the model: age
, gender
, and ethnicity
. How do I add this information to the model? Again, I want the model to predict a single prediction of age.
I looked at the Keras fit function documentation but couldn't figure it out. It says that y
is a "Vector, matrix, or array of target (label) data (or list if the model has multiple outputs)..."
EDIT:
That makes sense. Now the question is how do I set up the x
list? Here's what I have so far:
trainFeatures <- list(pixels = train_array, gender = as.factor(trainGenders), ethnicity = as.factor(trainEthnicity))
history <- model %>% fit(
x = trainFeatures, y = trainAge,
epochs = 10, batch_size = 30,
)
I downloaded a toy dataset and set up a quick CNN model. I got the following error message:
Error in py_get_attr_impl(x, name, silent) :
AttributeError: 'list' object has no attribute 'dtype'
r keras cnn
r keras cnn
edited Oct 10 '18 at 23:27
cooldood3490
asked Oct 10 '18 at 22:31
cooldood3490cooldood3490
1012
1012
bumped to the homepage by Community♦ 43 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 43 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
$begingroup$
I had the same error. I fixed it by transforming y to numeric type, it was factor and this raised the error.
$endgroup$
– kamelst
Mar 15 at 22:07
add a comment |
$begingroup$
I had the same error. I fixed it by transforming y to numeric type, it was factor and this raised the error.
$endgroup$
– kamelst
Mar 15 at 22:07
$begingroup$
I had the same error. I fixed it by transforming y to numeric type, it was factor and this raised the error.
$endgroup$
– kamelst
Mar 15 at 22:07
$begingroup$
I had the same error. I fixed it by transforming y to numeric type, it was factor and this raised the error.
$endgroup$
– kamelst
Mar 15 at 22:07
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
x
is an array/matrix of the inputs/features/independent variables.
y
is an array/matrix of the output(s)/target(s)/dependent variable(s).
Your x
array should contain the features extracted from the dataset of people's faces (however you may choose to do that). You can even include the gender and ethnicity alongside the features extracted from the dataset, if this information will be available to you while you deploy the model.
Your y
array should contain your target variable, i.e., the age associated with each face.
Response to EDIT:
Unfortunately, I actually haven't used Keras with R. But judging by the error you are seeing (and the prefix of the function), I would say it is most likely compatibility issues between R lists and whatever Keras expects underneath. Keras is implemented in Python, so it is probably expecting a Numpy array or just a Python list. I suspect you will have better luck creating an R data.frame
for your input features.
This tutorial I found might be helpful as it uses Keras and R to build a CNN.
$endgroup$
$begingroup$
I updated my question. How do I set up thex
array/matrix of the inputs/features/independent variables?
$endgroup$
– cooldood3490
Oct 10 '18 at 23:28
$begingroup$
@cooldood3490 updated the response
$endgroup$
– Anakimi
Oct 10 '18 at 23:54
add a comment |
Your Answer
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%2f39496%2fkeras-fit-function-r-train-regression-model-with-multiple-labels%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
$begingroup$
x
is an array/matrix of the inputs/features/independent variables.
y
is an array/matrix of the output(s)/target(s)/dependent variable(s).
Your x
array should contain the features extracted from the dataset of people's faces (however you may choose to do that). You can even include the gender and ethnicity alongside the features extracted from the dataset, if this information will be available to you while you deploy the model.
Your y
array should contain your target variable, i.e., the age associated with each face.
Response to EDIT:
Unfortunately, I actually haven't used Keras with R. But judging by the error you are seeing (and the prefix of the function), I would say it is most likely compatibility issues between R lists and whatever Keras expects underneath. Keras is implemented in Python, so it is probably expecting a Numpy array or just a Python list. I suspect you will have better luck creating an R data.frame
for your input features.
This tutorial I found might be helpful as it uses Keras and R to build a CNN.
$endgroup$
$begingroup$
I updated my question. How do I set up thex
array/matrix of the inputs/features/independent variables?
$endgroup$
– cooldood3490
Oct 10 '18 at 23:28
$begingroup$
@cooldood3490 updated the response
$endgroup$
– Anakimi
Oct 10 '18 at 23:54
add a comment |
$begingroup$
x
is an array/matrix of the inputs/features/independent variables.
y
is an array/matrix of the output(s)/target(s)/dependent variable(s).
Your x
array should contain the features extracted from the dataset of people's faces (however you may choose to do that). You can even include the gender and ethnicity alongside the features extracted from the dataset, if this information will be available to you while you deploy the model.
Your y
array should contain your target variable, i.e., the age associated with each face.
Response to EDIT:
Unfortunately, I actually haven't used Keras with R. But judging by the error you are seeing (and the prefix of the function), I would say it is most likely compatibility issues between R lists and whatever Keras expects underneath. Keras is implemented in Python, so it is probably expecting a Numpy array or just a Python list. I suspect you will have better luck creating an R data.frame
for your input features.
This tutorial I found might be helpful as it uses Keras and R to build a CNN.
$endgroup$
$begingroup$
I updated my question. How do I set up thex
array/matrix of the inputs/features/independent variables?
$endgroup$
– cooldood3490
Oct 10 '18 at 23:28
$begingroup$
@cooldood3490 updated the response
$endgroup$
– Anakimi
Oct 10 '18 at 23:54
add a comment |
$begingroup$
x
is an array/matrix of the inputs/features/independent variables.
y
is an array/matrix of the output(s)/target(s)/dependent variable(s).
Your x
array should contain the features extracted from the dataset of people's faces (however you may choose to do that). You can even include the gender and ethnicity alongside the features extracted from the dataset, if this information will be available to you while you deploy the model.
Your y
array should contain your target variable, i.e., the age associated with each face.
Response to EDIT:
Unfortunately, I actually haven't used Keras with R. But judging by the error you are seeing (and the prefix of the function), I would say it is most likely compatibility issues between R lists and whatever Keras expects underneath. Keras is implemented in Python, so it is probably expecting a Numpy array or just a Python list. I suspect you will have better luck creating an R data.frame
for your input features.
This tutorial I found might be helpful as it uses Keras and R to build a CNN.
$endgroup$
x
is an array/matrix of the inputs/features/independent variables.
y
is an array/matrix of the output(s)/target(s)/dependent variable(s).
Your x
array should contain the features extracted from the dataset of people's faces (however you may choose to do that). You can even include the gender and ethnicity alongside the features extracted from the dataset, if this information will be available to you while you deploy the model.
Your y
array should contain your target variable, i.e., the age associated with each face.
Response to EDIT:
Unfortunately, I actually haven't used Keras with R. But judging by the error you are seeing (and the prefix of the function), I would say it is most likely compatibility issues between R lists and whatever Keras expects underneath. Keras is implemented in Python, so it is probably expecting a Numpy array or just a Python list. I suspect you will have better luck creating an R data.frame
for your input features.
This tutorial I found might be helpful as it uses Keras and R to build a CNN.
edited Oct 10 '18 at 23:59
answered Oct 10 '18 at 22:42
AnakimiAnakimi
616
616
$begingroup$
I updated my question. How do I set up thex
array/matrix of the inputs/features/independent variables?
$endgroup$
– cooldood3490
Oct 10 '18 at 23:28
$begingroup$
@cooldood3490 updated the response
$endgroup$
– Anakimi
Oct 10 '18 at 23:54
add a comment |
$begingroup$
I updated my question. How do I set up thex
array/matrix of the inputs/features/independent variables?
$endgroup$
– cooldood3490
Oct 10 '18 at 23:28
$begingroup$
@cooldood3490 updated the response
$endgroup$
– Anakimi
Oct 10 '18 at 23:54
$begingroup$
I updated my question. How do I set up the
x
array/matrix of the inputs/features/independent variables?$endgroup$
– cooldood3490
Oct 10 '18 at 23:28
$begingroup$
I updated my question. How do I set up the
x
array/matrix of the inputs/features/independent variables?$endgroup$
– cooldood3490
Oct 10 '18 at 23:28
$begingroup$
@cooldood3490 updated the response
$endgroup$
– Anakimi
Oct 10 '18 at 23:54
$begingroup$
@cooldood3490 updated the response
$endgroup$
– Anakimi
Oct 10 '18 at 23:54
add a comment |
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%2f39496%2fkeras-fit-function-r-train-regression-model-with-multiple-labels%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$
I had the same error. I fixed it by transforming y to numeric type, it was factor and this raised the error.
$endgroup$
– kamelst
Mar 15 at 22:07