Confused about how to implement 2d input and 2d output regression model
See original GitHub issueI’m trying to build a regression model with 2d input and 2d output but I’m getting a bit confused about how to implement this. Taking the tutorial Coregionalized Regression Model as an example, I would just like to modify the model such that f_output1 and f_output2 are functions of two variables. I then thought I could simply change input_dim = 2 everywhere but this does not seem to work.
I’m pasting an example of the sort of thing I was trying below
f_output1 = lambda x, y: 4. * np.cos(x/5.) - .4*x - 35. + np.random.rand(x.size)[:,None] * 2. + y
f_output2 = lambda x, y: 6. * np.cos(x/5.) + .2*x + 35. + np.random.rand(x.size)[:,None] * 8. + 2*y
X1 = np.random.rand(100)[:,None]; X1=X1*75
X2 = np.random.rand(100)[:,None]; X2=X2*70 + 30
X2d = np.array([(X1.T)[0],(X2.T)[0]]).T # Put input data in the form I was expecting to be necessary based on multiple input examples in other tutorials
Y1 = f_output1(X1,X2)
Y2 = f_output2(X1,X2)
K = GPy.kern.Matern32(1)
icm = GPy.util.multioutput.ICM(input_dim=2,num_outputs=2,kernel=K)
m = GPy.models.GPCoregionalizedRegression([X2d,X2d],[Y1,Y2],kernel=icm)
m['.*Mat32.var'].constrain_fixed(1.) #For this kernel, B.kappa encodes the variance now.
m.optimize()
print(m)
Any help would be much appreciated. I’m very new to all this. Also, many thanks for your fantastic work.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to Develop Multi-Output Regression Models with Python
Multioutput regression are regression problems that involve predicting two or more numerical values given an input example.
Read more >Understanding Input Output shapes in Convolution Neural ...
Thus we have to change the dimension of output received from the convolution layer to a 2D array. Snippet-3. We can do it...
Read more >Machine learning with 2D matrix input and numerical output ...
I have a dataset, with a 2D matrix input for each point, and the corresponding target output value for that point. I am...
Read more >Keras: 2D input -> 2D output? - neural network - Stack Overflow
I'm quite new to keras and neural nets, and I only know how to deal with the label when it is one dimensional...
Read more >Keras: Multiple Inputs and Mixed Data - PyImageSearch
Multi-output models; Models that are both multiple input and multiple output; Directed acyclic graphs; Models with shared layers. For example, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Quick Question. So now you have a input_dim = 2, output_dim = 2, but how could you make a prediction, with m(np.asarray(X2d),Y_,etadata)? It always ask me:
AssertionError: need at least column vectors as inputs to kernels for now, given X2.shape=(1, 100, 2)
Any help is greatful!@SiyuanHuang95 To make predictions your inputs must be reshaped the same way as the model does shape it internally during training (i.e. adding an additional dimension indicating which input belongs to which output).
In the case that all outputs have common input values, this function might help.