[英]Setup linear regression with a factorMatrix - DL4j
I have a factorMatrix of type INDArray
which is xIn
我有一个 INDArray 类型的INDArray
,它是xIn
It contains of 5 columns [A, B, C, D, E]
它包含 5 列[A, B, C, D, E]
and another INDArray with 1 column [y]
which is yIn
和另一个具有 1 列[y]
的 INDArray,即yIn
For the ones who are familiar with MatLab I could use now:对于熟悉 MatLab 的人,我现在可以使用:
modelTrain = fitlm([XInSample yInSample] , 'linear') and then
retPredictionRegress = predict(modelTrain , XInSample);
I have issues to setup DL4J with xIn
and yInd
even when I found something that claims to be helpful - but at least not to me.我在使用xIn
和yInd
设置 DL4J 时遇到问题,即使我发现了一些声称有帮助的东西——但至少对我来说没有。
Could anyone please bring me on track?谁能带我走上正轨?
Linear regression in dl4j is just a neural network with a specific loss function and output later type. dl4j 中的线性回归只是一个具有特定损失的神经网络 function 和 output 后期类型。 This follows how you would do linear regression in any other deep learning framework.这遵循您将如何在任何其他深度学习框架中进行线性回归。 This concept/idea isn't really specific to dl4j itself.这个概念/想法并不是真正特定于 dl4j 本身。 It's following conventions you'd find in any instantation of the regression problem with a more general purpose framework.它遵循您在使用更通用框架的回归问题的任何实例中发现的约定。
I see you commented here as well: DL4J linear regression我看到你也在这里评论: DL4J 线性回归
Replying to your "at least not helpful to me", do you mind clarifying what you have issue with in the question?回复您的“至少对我没有帮助”,您介意澄清您在问题中遇到的问题吗? That would help a bit.那会有点帮助。
Answering your question, you'd just declare a neural network with your 5 inputs and declare how many ever inputs you have.回答您的问题,您只需声明一个具有 5 个输入的神经网络,并声明您有多少个输入。 You're allowed to declare more than 1 output if you find the objective to be suitable.如果您认为目标合适,您可以申报超过 1 个 output。 In your case it's 1 output.在您的情况下,它是 1 output。
An example of this would be:这方面的一个例子是:
//Create the network
int numInput = 5;
int numOutputs = 1;
int nHidden = 10;
MultiLayerNetwork net = new MultiLayerNetwork(new NeuralNetConfiguration.Builder()
.seed(seed)
.weightInit(WeightInit.XAVIER)
.updater(new Nesterovs(learningRate, 0.9))
.list()
.layer(0, new DenseLayer.Builder().nIn(numInput).nOut(nHidden)
.activation(Activation.TANH) //Change this to RELU and you will see the net learns very well very quickly
.build())
.layer(1, new OutputLayer.Builder(LossFunctions.LossFunction.MSE)
.activation(Activation.IDENTITY)
.nIn(nHidden).nOut(numOutputs).build())
.build()
);
The above snippet comes from the dl4j examples.上面的代码片段来自 dl4j 示例。
In this case, you would be working on tuning the neural network with the appropriate output.在这种情况下,您将使用适当的 output 调整神经网络。 I would suggest doing some broader reading on the topic if you want to understand the relationship between neural nets and regression.如果您想了解神经网络和回归之间的关系,我建议您对该主题进行一些更广泛的阅读。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.