1
$\begingroup$

I am an enthusiast of neural network and regularly I try to model simple models in NN. While thinking about neural network's application in artificial intelligence I had this doubt arise in my mind whether a single neural network can solve multiple tasks or problems. A neural network trained to classify digits from images can also be used "simultaneously" for other task such as writing an original article. I know we can retrain same neural network depending on the task but I am not looking for that. In order to check my doubt I created a neural network which should in theory will solve two continuous equations (will add more equations in future) and this is my code

library(caret)
set.seed(2016)
#first equation 
equ1<-function(x){
    v=x^3/(2*tan(x))
  return(v)
}
#second equation
equ2<-function(x){
  v=sin(x^2)/2*x    
  return(v)
}
X=(1:50)
Y1=equ1(X)
Y2=equ2(X)
I=cbind(X,Y1,Y2)
I=data.frame(I)

ctrl <- trainControl(method = "cv",number=10, verboseIter = TRUE, savePred=T)
model <- train(Y1+Y2~X, data=I, method ="nnet", trControl = ctrl,verbose = TRUE)

print(model)

and the out put is this

  size  decay  RMSE      Rsquared    RMSE SD   Rsquared SD
  1     0e+00  187737.1         NaN  373322.1         NA  
  1     1e-04  187737.1         NaN  373322.1         NA  
  1     1e-01  187737.1  0.09728231  373322.1         NA  
  3     0e+00  187737.1         NaN  373322.1         NA  
  3     1e-04  187737.1         NaN  373322.1         NA  
  3     1e-01  187737.1  0.15565127  373322.1  0.1361369  
  5     0e+00  187737.1         NaN  373322.1         NA  
  5     1e-04  187737.1         NaN  373322.1         NA  
  5     1e-01  187737.1  0.30146221  373322.1  0.2960712  

From the result we can see that its RMSE value is way greater and non of the models can be used for solving the two equations?

1Q.Does a single neural network can solve multiple tasks? 
2Q.If yes,Did I made any error in my code which is giving me negative results?
3Q.Can anyone share any neural network example which can be successfully used for different tasks(without retraining them)?
$\endgroup$
1
$\begingroup$

Yes, a network can perform multiple tasks. Here's a simple example. Say network $N_1$ computes function $f_1$ and network $N_2$ computes function $f_2$. Both contain $n_{in}$ input units. Construct a new network $N_3$ with $n_{in}$ input units. The hidden and output layers of $N_3$ are side-by-side, concatenated copies of those of $N_1$ and $N_2$. So, $N_3$ has two sets of outputs. The first set (matching $N_1$) will return the output of $f_1$. The second set (matching $N_2$) will return the output of $f_2$.

That describes how to construct a new, multi-function network out of individual, trained, single-function networks. However, it should also be possible to train a multi-function network $N_4$ from the ground up. Such a network would have multiple sets of outputs (one for each function), and the loss function would be written to take this into account. Network $N_3$ (above) consists of parallel, independent subnetworks; the weight matrices have a block structure such that the hidden units within each subnetwork don't interact. But, the functions computed by $N_4$ might end up 'sharing' hidden units.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.