Autoencoder and SVD: Matrix apllications
in my study, I am using the so-called Lee Carter Model (Mortality model) in which you can get the model parameters by using Singular Values Decomposition on the matrix of (log mortality rate- the average age-specific pattern of mortality).
I am trying to find a substitution of Singular Value Decomposition, I saw that a good choice could be an autoencoding applied by a Recurrent Neural network. In fact, an SVD could be converging to autoencoder in which the activation function is a linear function. At this purpose, I would try using a nonlinear activation function in order to obtain the same items obtained by SVD with a nonlinear shape.
Let's use this steps in order to obtain data: mortality rates for ages and years
rm(list = ls())
library(MortalitySmooth)
ages <- 0:100
years <- 1960:2009
D <- as.matrix(selectHMDdata("Japan", "Deaths",
"Females", ages,
years))
D[D==0] <- 1
E <- as.matrix(selectHMDdata("Japan", "Exposures",
"Females", ages,
years))
E[E==0] <- 1
lMX <- log(D/E)
alpha <- apply(lMX, 1, mean)`
cent.logMXMatrix <- sweep(lMX, 1, alpha)
Now we apply SVD on cent.logMXMatrix
when I use SVD in R I get this:
SVD <- svd(cent.logMXMatrix)
and I need to get the components of SVD:
SVD$d
SVD$v
SVD$u
I would like to get SVD component using Autoencoder...Is it possible?
I would like to get your opinion, some suggestion from you and whether is possible I need a basic python code formulation for autoencoder on the "cent.logMXMatrix"
Thank a lot,
Andrea
python matrix autoencoder svd
add a comment |
in my study, I am using the so-called Lee Carter Model (Mortality model) in which you can get the model parameters by using Singular Values Decomposition on the matrix of (log mortality rate- the average age-specific pattern of mortality).
I am trying to find a substitution of Singular Value Decomposition, I saw that a good choice could be an autoencoding applied by a Recurrent Neural network. In fact, an SVD could be converging to autoencoder in which the activation function is a linear function. At this purpose, I would try using a nonlinear activation function in order to obtain the same items obtained by SVD with a nonlinear shape.
Let's use this steps in order to obtain data: mortality rates for ages and years
rm(list = ls())
library(MortalitySmooth)
ages <- 0:100
years <- 1960:2009
D <- as.matrix(selectHMDdata("Japan", "Deaths",
"Females", ages,
years))
D[D==0] <- 1
E <- as.matrix(selectHMDdata("Japan", "Exposures",
"Females", ages,
years))
E[E==0] <- 1
lMX <- log(D/E)
alpha <- apply(lMX, 1, mean)`
cent.logMXMatrix <- sweep(lMX, 1, alpha)
Now we apply SVD on cent.logMXMatrix
when I use SVD in R I get this:
SVD <- svd(cent.logMXMatrix)
and I need to get the components of SVD:
SVD$d
SVD$v
SVD$u
I would like to get SVD component using Autoencoder...Is it possible?
I would like to get your opinion, some suggestion from you and whether is possible I need a basic python code formulation for autoencoder on the "cent.logMXMatrix"
Thank a lot,
Andrea
python matrix autoencoder svd
SVD is a linear algebra problem. You can use a pseudo autoencoder with just 2 linear layers to get it, of course.
– Matthieu Brucher
Nov 19 '18 at 10:30
Thanks, can you show me?
– an.dr.ea
Nov 20 '18 at 11:16
add a comment |
in my study, I am using the so-called Lee Carter Model (Mortality model) in which you can get the model parameters by using Singular Values Decomposition on the matrix of (log mortality rate- the average age-specific pattern of mortality).
I am trying to find a substitution of Singular Value Decomposition, I saw that a good choice could be an autoencoding applied by a Recurrent Neural network. In fact, an SVD could be converging to autoencoder in which the activation function is a linear function. At this purpose, I would try using a nonlinear activation function in order to obtain the same items obtained by SVD with a nonlinear shape.
Let's use this steps in order to obtain data: mortality rates for ages and years
rm(list = ls())
library(MortalitySmooth)
ages <- 0:100
years <- 1960:2009
D <- as.matrix(selectHMDdata("Japan", "Deaths",
"Females", ages,
years))
D[D==0] <- 1
E <- as.matrix(selectHMDdata("Japan", "Exposures",
"Females", ages,
years))
E[E==0] <- 1
lMX <- log(D/E)
alpha <- apply(lMX, 1, mean)`
cent.logMXMatrix <- sweep(lMX, 1, alpha)
Now we apply SVD on cent.logMXMatrix
when I use SVD in R I get this:
SVD <- svd(cent.logMXMatrix)
and I need to get the components of SVD:
SVD$d
SVD$v
SVD$u
I would like to get SVD component using Autoencoder...Is it possible?
I would like to get your opinion, some suggestion from you and whether is possible I need a basic python code formulation for autoencoder on the "cent.logMXMatrix"
Thank a lot,
Andrea
python matrix autoencoder svd
in my study, I am using the so-called Lee Carter Model (Mortality model) in which you can get the model parameters by using Singular Values Decomposition on the matrix of (log mortality rate- the average age-specific pattern of mortality).
I am trying to find a substitution of Singular Value Decomposition, I saw that a good choice could be an autoencoding applied by a Recurrent Neural network. In fact, an SVD could be converging to autoencoder in which the activation function is a linear function. At this purpose, I would try using a nonlinear activation function in order to obtain the same items obtained by SVD with a nonlinear shape.
Let's use this steps in order to obtain data: mortality rates for ages and years
rm(list = ls())
library(MortalitySmooth)
ages <- 0:100
years <- 1960:2009
D <- as.matrix(selectHMDdata("Japan", "Deaths",
"Females", ages,
years))
D[D==0] <- 1
E <- as.matrix(selectHMDdata("Japan", "Exposures",
"Females", ages,
years))
E[E==0] <- 1
lMX <- log(D/E)
alpha <- apply(lMX, 1, mean)`
cent.logMXMatrix <- sweep(lMX, 1, alpha)
Now we apply SVD on cent.logMXMatrix
when I use SVD in R I get this:
SVD <- svd(cent.logMXMatrix)
and I need to get the components of SVD:
SVD$d
SVD$v
SVD$u
I would like to get SVD component using Autoencoder...Is it possible?
I would like to get your opinion, some suggestion from you and whether is possible I need a basic python code formulation for autoencoder on the "cent.logMXMatrix"
Thank a lot,
Andrea
python matrix autoencoder svd
python matrix autoencoder svd
edited Nov 18 '18 at 12:58
Dmitriy Fialkovskiy
1,59521425
1,59521425
asked Nov 18 '18 at 12:05
an.dr.eaan.dr.ea
44
44
SVD is a linear algebra problem. You can use a pseudo autoencoder with just 2 linear layers to get it, of course.
– Matthieu Brucher
Nov 19 '18 at 10:30
Thanks, can you show me?
– an.dr.ea
Nov 20 '18 at 11:16
add a comment |
SVD is a linear algebra problem. You can use a pseudo autoencoder with just 2 linear layers to get it, of course.
– Matthieu Brucher
Nov 19 '18 at 10:30
Thanks, can you show me?
– an.dr.ea
Nov 20 '18 at 11:16
SVD is a linear algebra problem. You can use a pseudo autoencoder with just 2 linear layers to get it, of course.
– Matthieu Brucher
Nov 19 '18 at 10:30
SVD is a linear algebra problem. You can use a pseudo autoencoder with just 2 linear layers to get it, of course.
– Matthieu Brucher
Nov 19 '18 at 10:30
Thanks, can you show me?
– an.dr.ea
Nov 20 '18 at 11:16
Thanks, can you show me?
– an.dr.ea
Nov 20 '18 at 11:16
add a comment |
1 Answer
1
active
oldest
votes
A one-layer autoencoder linearly maps a datapoint to a low-dimensional latent space, then applies a non-linear activation to project the result to the original space while minimizing a reconstruction error.
If we replace the non-linear activation by a linear one (identity) and use the L2 norm as a reconstruction error, you will be performing the same operation as an SVD.
# use keras with tensorflow backend
# This is a vanilla autoencoder with one hidden layer
from keras.layers import Input, Dense
from keras.models import Model
input_dim = Input(shape = (nfeat, )) # nfeat=the number of initial features
encoded1 = Dense(layer_size1, activation='linear')(input_dim) # layer_size1:size of your encoding layer
decoded1 = Dense(nfeat, activation='linear')
autoencoder = Model(inputs = input_dim, outputs = decoded1)
autoencoder.compile(loss='mean_squared_error', optimizer='adam')
1
No need for more layers in a linear encoder. But thanks for showing the code for OP. Even here, you should have only 2 layers, not three. Which is why I'm not up voting.
– Matthieu Brucher
Nov 20 '18 at 14:37
@MatthieuBrucher You're right. Since we have linear activation, no need to add more layers. Sorry for this !
– Akihiko
Nov 20 '18 at 15:09
Thanks for fixing this!
– Matthieu Brucher
Nov 20 '18 at 15:23
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%2f53360675%2fautoencoder-and-svd-matrix-apllications%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
A one-layer autoencoder linearly maps a datapoint to a low-dimensional latent space, then applies a non-linear activation to project the result to the original space while minimizing a reconstruction error.
If we replace the non-linear activation by a linear one (identity) and use the L2 norm as a reconstruction error, you will be performing the same operation as an SVD.
# use keras with tensorflow backend
# This is a vanilla autoencoder with one hidden layer
from keras.layers import Input, Dense
from keras.models import Model
input_dim = Input(shape = (nfeat, )) # nfeat=the number of initial features
encoded1 = Dense(layer_size1, activation='linear')(input_dim) # layer_size1:size of your encoding layer
decoded1 = Dense(nfeat, activation='linear')
autoencoder = Model(inputs = input_dim, outputs = decoded1)
autoencoder.compile(loss='mean_squared_error', optimizer='adam')
1
No need for more layers in a linear encoder. But thanks for showing the code for OP. Even here, you should have only 2 layers, not three. Which is why I'm not up voting.
– Matthieu Brucher
Nov 20 '18 at 14:37
@MatthieuBrucher You're right. Since we have linear activation, no need to add more layers. Sorry for this !
– Akihiko
Nov 20 '18 at 15:09
Thanks for fixing this!
– Matthieu Brucher
Nov 20 '18 at 15:23
add a comment |
A one-layer autoencoder linearly maps a datapoint to a low-dimensional latent space, then applies a non-linear activation to project the result to the original space while minimizing a reconstruction error.
If we replace the non-linear activation by a linear one (identity) and use the L2 norm as a reconstruction error, you will be performing the same operation as an SVD.
# use keras with tensorflow backend
# This is a vanilla autoencoder with one hidden layer
from keras.layers import Input, Dense
from keras.models import Model
input_dim = Input(shape = (nfeat, )) # nfeat=the number of initial features
encoded1 = Dense(layer_size1, activation='linear')(input_dim) # layer_size1:size of your encoding layer
decoded1 = Dense(nfeat, activation='linear')
autoencoder = Model(inputs = input_dim, outputs = decoded1)
autoencoder.compile(loss='mean_squared_error', optimizer='adam')
1
No need for more layers in a linear encoder. But thanks for showing the code for OP. Even here, you should have only 2 layers, not three. Which is why I'm not up voting.
– Matthieu Brucher
Nov 20 '18 at 14:37
@MatthieuBrucher You're right. Since we have linear activation, no need to add more layers. Sorry for this !
– Akihiko
Nov 20 '18 at 15:09
Thanks for fixing this!
– Matthieu Brucher
Nov 20 '18 at 15:23
add a comment |
A one-layer autoencoder linearly maps a datapoint to a low-dimensional latent space, then applies a non-linear activation to project the result to the original space while minimizing a reconstruction error.
If we replace the non-linear activation by a linear one (identity) and use the L2 norm as a reconstruction error, you will be performing the same operation as an SVD.
# use keras with tensorflow backend
# This is a vanilla autoencoder with one hidden layer
from keras.layers import Input, Dense
from keras.models import Model
input_dim = Input(shape = (nfeat, )) # nfeat=the number of initial features
encoded1 = Dense(layer_size1, activation='linear')(input_dim) # layer_size1:size of your encoding layer
decoded1 = Dense(nfeat, activation='linear')
autoencoder = Model(inputs = input_dim, outputs = decoded1)
autoencoder.compile(loss='mean_squared_error', optimizer='adam')
A one-layer autoencoder linearly maps a datapoint to a low-dimensional latent space, then applies a non-linear activation to project the result to the original space while minimizing a reconstruction error.
If we replace the non-linear activation by a linear one (identity) and use the L2 norm as a reconstruction error, you will be performing the same operation as an SVD.
# use keras with tensorflow backend
# This is a vanilla autoencoder with one hidden layer
from keras.layers import Input, Dense
from keras.models import Model
input_dim = Input(shape = (nfeat, )) # nfeat=the number of initial features
encoded1 = Dense(layer_size1, activation='linear')(input_dim) # layer_size1:size of your encoding layer
decoded1 = Dense(nfeat, activation='linear')
autoencoder = Model(inputs = input_dim, outputs = decoded1)
autoencoder.compile(loss='mean_squared_error', optimizer='adam')
edited Nov 20 '18 at 15:13
answered Nov 20 '18 at 12:46
AkihikoAkihiko
557
557
1
No need for more layers in a linear encoder. But thanks for showing the code for OP. Even here, you should have only 2 layers, not three. Which is why I'm not up voting.
– Matthieu Brucher
Nov 20 '18 at 14:37
@MatthieuBrucher You're right. Since we have linear activation, no need to add more layers. Sorry for this !
– Akihiko
Nov 20 '18 at 15:09
Thanks for fixing this!
– Matthieu Brucher
Nov 20 '18 at 15:23
add a comment |
1
No need for more layers in a linear encoder. But thanks for showing the code for OP. Even here, you should have only 2 layers, not three. Which is why I'm not up voting.
– Matthieu Brucher
Nov 20 '18 at 14:37
@MatthieuBrucher You're right. Since we have linear activation, no need to add more layers. Sorry for this !
– Akihiko
Nov 20 '18 at 15:09
Thanks for fixing this!
– Matthieu Brucher
Nov 20 '18 at 15:23
1
1
No need for more layers in a linear encoder. But thanks for showing the code for OP. Even here, you should have only 2 layers, not three. Which is why I'm not up voting.
– Matthieu Brucher
Nov 20 '18 at 14:37
No need for more layers in a linear encoder. But thanks for showing the code for OP. Even here, you should have only 2 layers, not three. Which is why I'm not up voting.
– Matthieu Brucher
Nov 20 '18 at 14:37
@MatthieuBrucher You're right. Since we have linear activation, no need to add more layers. Sorry for this !
– Akihiko
Nov 20 '18 at 15:09
@MatthieuBrucher You're right. Since we have linear activation, no need to add more layers. Sorry for this !
– Akihiko
Nov 20 '18 at 15:09
Thanks for fixing this!
– Matthieu Brucher
Nov 20 '18 at 15:23
Thanks for fixing this!
– Matthieu Brucher
Nov 20 '18 at 15:23
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%2f53360675%2fautoencoder-and-svd-matrix-apllications%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
SVD is a linear algebra problem. You can use a pseudo autoencoder with just 2 linear layers to get it, of course.
– Matthieu Brucher
Nov 19 '18 at 10:30
Thanks, can you show me?
– an.dr.ea
Nov 20 '18 at 11:16