Map vector to vector with neural network or other black box model
6 次查看(过去 30 天)
显示 更早的评论
I want to find a mapping function which can map two vectors:
The size of x is 3 and y is 4.
There're nonlinear realationships between these 2 vectors, which is
It's that clear it's impossible to get y analytically.
Since I'm new to machine learning, I wonder if it is possible to use neural networks or other black box models to do this mapping, and what kind of models would you recommend more?
(For those of you interested in specific scenario: This is the conversion of parameters between two induction motor steady state model, inverse Γ model and T model. There are redundancies in T model, and inverse model is the simplified model without redundancies.)
0 个评论
回答(1 个)
Ayush Anand
2023-11-26
编辑:Ayush Anand
2023-11-28
Hi Raymond,
I understand you have two vectors "x" and "y" of sizes 3 and 4 with a non-linear relationship between them. It is clear that "y" cannot be obtained analytically from "x", and you want to know if there is a way to train a neural network or other similar models to learn the mapping between the two.
Given the nonlinear relationships between the vectors "x" and "y" that you've described, it is indeed possible to use machine learning models, such as neural networks, to approximate the inverse mapping from "x" to "y". Since you have explicit formulas for "x" in terms of "y", you can generate a synthetic dataset where you sample values of "y" and calculate the corresponding "x" values. With this dataset, you can train a model to learn the mapping from "x" back to "y".
Here's an example of how you might implement this in MATLAB:
% Generate a dataset of x and y pairs
N = 10000; % Number of data points
Y = rand(N, 4); % Randomly generate Y vectors
X = [Y(:,1) + Y(:,3) - Y(:,3).^2 ./ (Y(:,2) + Y(:,3)), ...
Y(:,3).^2 ./ (Y(:,2) + Y(:,3)), ...
Y(:,3) .* Y(:,4) ./ (Y(:,2) + Y(:,3)).^2]; % Calculate corresponding X vectors
% Now we need to choose a machine learning model. A feedforward neural network with one or more hidden layers could work well for this task.
% Create a feedforward neural network
layers = [
featureInputLayer(3, 'Normalization', 'zscore')
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(4) % Output layer size is 4, since Y has 4 elements
regressionLayer];
% Training the model
% Set training options; you can experiment with these according to your needs
options = trainingOptions('adam', ...
'MaxEpochs',1000, ...
'MiniBatchSize', 64, ...
'InitialLearnRate', 1e-3, ...
'LearnRateSchedule', 'piecewise', ...
'LearnRateDropPeriod', 25, ...
'LearnRateDropFactor', 0.8, ...
'Shuffle', 'every-epoch', ...
'ValidationData', {X, Y}, ...
'ValidationFrequency', 30, ...
'Verbose', false, ...
'Plots', 'training-progress');
% Train the neural network
net = trainNetwork(X, Y, layers, options);
% Predict Y from new X using our trained model
new_X = [0.5, 0.2, 0.3]; % Example new X vector
predicted_Y = predict(net, new_X);
% Display the predicted Y
disp(predicted_Y);
I hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!