Class FMParameters
java.lang.Object
org.tribuo.common.sgd.FMParameters
- All Implemented Interfaces:
Serializable,FeedForwardParameters,Parameters,ProtoSerializable<org.tribuo.math.protos.ParametersProto>
A
Parameters for factorization machines.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProtobuf serialization version.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionFMParameters(SplittableRandom rng, int numFeatures, int numLabels, int numFactors, double variance) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()static FMParametersdeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.Tensor[]get()Tensor[]This returns aDenseMatrixthe same size as the Parameters.Tensor[]Generate the gradients for a particular feature vector given the loss and the per output gradients.Tensor[]Generates an unnormalised prediction by multiplying the weights with the incoming features, adding the bias and adding the feature factors.org.tribuo.math.protos.ParametersProtovoidvoid
-
Field Details
-
CURRENT_VERSION
-
-
Constructor Details
-
FMParameters
public FMParameters(SplittableRandom rng, int numFeatures, int numLabels, int numFactors, double variance) Constructor. The number of features and the number of outputs must be fixed and known in advance.- Parameters:
rng- The RNG to use for initialization.numFeatures- The number of features in the training dataset.numLabels- The number of outputs in the training dataset.numFactors- The size of the factorized feature representation.variance- The variance of the factor initializer.
-
-
Method Details
-
deserializeFromProto
public static FMParameters deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException Deserialization factory.- Parameters:
version- The serialized object version.className- The class name.message- The serialized data.- Returns:
- The deserialized object.
- Throws:
com.google.protobuf.InvalidProtocolBufferException- If the protobuf could not be parsed from themessage.
-
serialize
- Specified by:
serializein interfaceProtoSerializable<org.tribuo.math.protos.ParametersProto>
-
predict
Generates an unnormalised prediction by multiplying the weights with the incoming features, adding the bias and adding the feature factors.- Specified by:
predictin interfaceFeedForwardParameters- Parameters:
example- A feature vector- Returns:
- A
DenseVectorcontaining a score for each label.
-
gradients
public Tensor[] gradients(com.oracle.labs.mlrg.olcut.util.Pair<Double, SGDVector> score, SGDVector features) Generate the gradients for a particular feature vector given the loss and the per output gradients.This method returns a
Tensorarray with numLabels + 2 elements.- Specified by:
gradientsin interfaceFeedForwardParameters- Parameters:
score- The Pair returned by the objective.features- The feature vector.- Returns:
- A
Tensorarray containing all the gradients.
-
getEmptyCopy
This returns aDenseMatrixthe same size as the Parameters.- Specified by:
getEmptyCopyin interfaceParameters- Returns:
- A
Tensorarray containing a singleDenseMatrix.
-
get
- Specified by:
getin interfaceParameters
-
set
- Specified by:
setin interfaceParameters
-
update
- Specified by:
updatein interfaceParameters
-
merge
- Specified by:
mergein interfaceParameters
-
copy
- Specified by:
copyin interfaceFeedForwardParameters
-