public class NeuralNetworkModel extends LTRScoringModel
Supported activation functions are:
identity
, relu
, sigmoid
, tanh
, leakyrelu
and
contributions to support additional activation functions are welcome.
Example configuration:
{ "class" : "org.apache.solr.ltr.model.NeuralNetworkModel", "name" : "rankNetModel", "features" : [ { "name" : "documentRecency" }, { "name" : "isBook" }, { "name" : "originalScore" } ], "params" : { "layers" : [ { "matrix" : [ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ], [ 7.0, 8.0, 9.0 ], [ 10.0, 11.0, 12.0 ] ], "bias" : [ 13.0, 14.0, 15.0, 16.0 ], "activation" : "sigmoid" }, { "matrix" : [ [ 17.0, 18.0, 19.0, 20.0 ], [ 21.0, 22.0, 23.0, 24.0 ] ], "bias" : [ 25.0, 26.0 ], "activation" : "relu" }, { "matrix" : [ [ 27.0, 28.0 ], [ 29.0, 30.0 ] ], "bias" : [ 31.0, 32.0 ], "activation" : "leakyrelu" }, { "matrix" : [ [ 33.0, 34.0 ], [ 35.0, 36.0 ] ], "bias" : [ 37.0, 38.0 ], "activation" : "tanh" }, { "matrix" : [ [ 39.0, 40.0 ] ], "bias" : [ 41.0 ], "activation" : "identity" } ] } }
Training libraries:
Background reading:
Modifier and Type | Class and Description |
---|---|
protected static interface |
NeuralNetworkModel.Activation |
class |
NeuralNetworkModel.DefaultLayer |
static interface |
NeuralNetworkModel.Layer |
features, name, norms
NULL_ACCOUNTABLE
Constructor and Description |
---|
NeuralNetworkModel(String name,
List<Feature> features,
List<Normalizer> norms,
String featureStoreName,
List<Feature> allFeatures,
Map<String,Object> params) |
Modifier and Type | Method and Description |
---|---|
protected NeuralNetworkModel.Layer |
createLayer(Object o) |
Explanation |
explain(LeafReaderContext context,
int doc,
float finalScore,
List<Explanation> featureExplanations)
Similar to the score() function, except it returns an explanation of how
the features were used to calculate the score.
|
float |
score(float[] inputFeatures)
Given a list of normalized values for all features a scoring algorithm
cares about, calculate and return a score.
|
void |
setLayers(Object layers) |
protected void |
validate()
Validate that settings make sense and throws
ModelException if they do not make sense. |
equals, getAllFeatures, getFeatures, getFeatureStoreName, getInstance, getName, getNormalizerExplanation, getNorms, getParams, hashCode, normalizeFeaturesInPlace, ramBytesUsed, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getChildResources
protected NeuralNetworkModel.Layer createLayer(Object o)
public void setLayers(Object layers)
protected void validate() throws ModelException
LTRScoringModel
ModelException
if they do not make sense.validate
in class LTRScoringModel
ModelException
public float score(float[] inputFeatures)
LTRScoringModel
score
in class LTRScoringModel
inputFeatures
- List of normalized feature values. Each feature is identified by
its id, which is the index in the arraypublic Explanation explain(LeafReaderContext context, int doc, float finalScore, List<Explanation> featureExplanations)
LTRScoringModel
explain
in class LTRScoringModel
context
- Context the document is indoc
- Document to explainfinalScore
- Original scorefeatureExplanations
- Explanations for each feature calculationCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.