* VectorGaussian.SetToRatio correctly enforces forceProper
* BeliefPropagationGateEnterPartialOp.ValueAverageConditional double-checks for conflicting values
* Added ReplicateOp_Divide_NoInit
* PlusProductHierarchyTest is OpenBug
* MatrixVectorProduct has optional check
* Deterministic gates track the number of cases
This commit is contained in:
Tom Minka 2022-05-03 22:27:20 +01:00 коммит произвёл GitHub
Родитель ca25068ead
Коммит 55d26a7138
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
40 изменённых файлов: 1380 добавлений и 935 удалений

Просмотреть файл

@ -7,17 +7,17 @@ using System.Collections.Generic;
namespace Microsoft.ML.Probabilistic.Compiler.Graphs
{
internal struct IndexedProperty<KeyType, ValueType>
internal class IndexedProperty<KeyType, ValueType>
{
/// <summary>
/// Delegate for retrieving data at an index.
/// </summary>
public Converter<KeyType, ValueType> Get;
public readonly Converter<KeyType, ValueType> Get;
/// <summary>
/// Delegate for setting data at an index.
/// </summary>
public Action<KeyType, ValueType> Set;
public readonly Action<KeyType, ValueType> Set;
/// <summary>
/// Delegate for clearing the mapping.
@ -26,7 +26,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Graphs
/// If the mapping has a default value, this sets all data to that value.
/// Otherwise the mapping is undefined at all values.
/// </remarks>
public Action Clear;
public readonly Action Clear;
/// <summary>
/// Get or set data at an index.

Просмотреть файл

@ -261,12 +261,12 @@ namespace Microsoft.ML.Probabilistic.Compiler.Graphs
/// <typeparam name="EdgeType"></typeparam>
internal class EdgeOnPathFinder<NodeType, EdgeType>
{
private Converter<NodeType, IEnumerable<EdgeType>> edgesOutOf;
private Converter<EdgeType, NodeType> targetOf;
public IndexedProperty<NodeType, bool> isBlocked;
private IndexedProperty<NodeType, Set<NodeType>> blockedSources;
private IndexedProperty<EdgeType, bool> onPath;
private Predicate<NodeType> isSink;
private readonly Converter<NodeType, IEnumerable<EdgeType>> edgesOutOf;
private readonly Converter<EdgeType, NodeType> targetOf;
public readonly IndexedProperty<NodeType, bool> isBlocked;
private readonly IndexedProperty<NodeType, Set<NodeType>> blockedSources;
private readonly IndexedProperty<EdgeType, bool> onPath;
private readonly Predicate<NodeType> isSink;
public EdgeOnPathFinder(
Converter<NodeType, IEnumerable<EdgeType>> edgesOutOf,

Просмотреть файл

@ -899,7 +899,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Attributes
if (containers.Count == 0) return stmts;
else
{
IList<IStatement> result = Builder.StmtCollection();
List<IStatement> result = new List<IStatement>();
AddStatementWithContainers(result, stmts, containers);
return result;
}
@ -961,8 +961,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Attributes
internal static void AddStatementWithContainers(IList<IStatement> statementsDest, IStatement statement, ICollection<IStatement> containers)
{
IList<IStatement> statementsSource = Builder.StmtCollection();
statementsSource.Add(statement);
List<IStatement> statementsSource = new List<IStatement>() { statement };
AddStatementWithContainers(statementsDest, statementsSource, containers);
}
@ -1001,7 +1000,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Attributes
Statements(container).Add(statement);
}
internal static void AddToContainer(IStatement container, IList<IStatement> statements)
internal static void AddToContainer(IStatement container, IEnumerable<IStatement> statements)
{
Statements(container).AddRange(statements);
}

Просмотреть файл

@ -3813,6 +3813,24 @@ namespace Microsoft.ML.Probabilistic.Models
return first;
}
/// <summary>
/// Creates two copies of the argument, that will be updated in order during inference.
/// </summary>
/// <typeparam name="T">The domain type of an array element.</typeparam>
/// <param name="array">Array to copy.</param>
/// <param name="second">The second copy.</param>
/// <returns>The first copy.</returns>
public static VariableArray<T> ParallelCopy<T>(VariableArray<T> array, out VariableArray<T> second)
{
var range = array.Range;
var first = Variable.Array<T>(range);
CreateVariableArray(first, array);
second = Variable.Array<T>(range);
CreateVariableArray(second, array);
first[range] = Variable<T>.Factor(LowPriority.ParallelCopy<T>, array[range], second[range]);
return first;
}
/// <summary>
/// Creates two copies of the argument, that will be updated in order during inference.
/// </summary>

Просмотреть файл

@ -9,7 +9,6 @@ using System.Text;
using System.Linq;
using System.Reflection;
using Microsoft.ML.Probabilistic.Compiler.Attributes;
using Microsoft.ML.Probabilistic.Compiler;
using Microsoft.ML.Probabilistic.Compiler.CodeModel;
using Microsoft.ML.Probabilistic.Utilities;
using Microsoft.ML.Probabilistic.Collections;
@ -69,19 +68,19 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// </summary>
private DependencyType dependencyType;
private Set<IExpression> mutatedExpressions = new Set<IExpression>();
private readonly Set<IExpression> mutatedExpressions = new Set<IExpression>();
/// <summary>
/// The set of parameter declarations for the top-level method being transformed.
/// </summary>
private Set<IParameterDeclaration> topLevelParameters = new Set<IParameterDeclaration>();
private readonly Set<IParameterDeclaration> topLevelParameters = new Set<IParameterDeclaration>();
private LoopMergingInfo loopMergingInfo;
/// <summary>
/// Records all times that a variable is declared or assigned to
/// </summary>
private Dictionary<IVariableDeclaration, MutationInformation> mutInfos =
private readonly Dictionary<IVariableDeclaration, MutationInformation> mutInfos =
new Dictionary<IVariableDeclaration, MutationInformation>(ReferenceEqualityComparer<IVariableDeclaration>.Instance);
private bool convertingLoopInitializer;
@ -670,7 +669,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
context.InputAttributes.Set(loopVar, new LoopCounterAttribute());
}
}
if ((ibe.Right is ILiteralExpression) && 0.Equals(((ILiteralExpression)ibe.Right).Value))
if ((ibe.Right is ILiteralExpression ile) && 0.Equals(ile.Value))
{
// loop of zero length
return null;
@ -756,7 +755,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
bool isUniform = false;
foreach (IExpression dim in iace.Dimensions)
{
if ((dim is ILiteralExpression) && 0.Equals(((ILiteralExpression)dim).Value))
if ((dim is ILiteralExpression ile) && 0.Equals(ile.Value))
{
isUniform = true;
}

Просмотреть файл

@ -1712,7 +1712,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
public void AddEvent(NodeIndex node, string message)
{
if (EventHistory.Get != null)
if (EventHistory != null)
{
EventHistory[node].Add(String.Format("[{0}] {1}", EventCounter++, message));
}

Просмотреть файл

@ -294,6 +294,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
Dictionary<string, IExpression> dependencyExpr = new Dictionary<string, IExpression>();
foreach (ParameterInfo parameter in parameters)
{
if (parameter.IsDefined(typeof(IgnoreDeclarationAttribute), false)) continue;
IExpression paramRef = Builder.ParamRef(Builder.Param(parameter.Name, parameter.ParameterType));
IExpression dependency = paramRef;
bool isConstant = false;
@ -334,6 +335,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
FactorEdge edge = fcnInfo.factorEdgeOfParameter[parameter.Name];
string originalName = edge.ParameterName;
// A buffer will appear in factorEdgeOfParameter but not factorInfo.ParameterTypes
if (factorInfo.ParameterTypes.ContainsKey(originalName))
{
isConstant = factorInfo.ParameterTypes[originalName].IsAssignableFrom(parameter.ParameterType);
@ -345,7 +347,11 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
}
}
}
if (parameter.IsDefined(typeof(IgnoreDeclarationAttribute), false)) continue;
else
{
// The method is not a message operator.
// isConstant=false because the method may not require the argument to be updated, e.g. MakeUniform.
}
IStatement dependencySt = Builder.ExprStatement(dependency);
if ((parameter.Name == "resultIndex") ||
(parameter.Name == "result") ||

Просмотреть файл

@ -70,12 +70,16 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
}
bool isStochastic = CodeRecognizer.IsStochastic(context, binding.lhs);
IExpression gateBlockKey;
if (isStochastic)
if (isStochastic || GateTransform.DeterministicEnterExit)
{
gateBlockKey = binding.lhs;
}
else
{
// definitions must not be unified across deterministic gate conditions
gateBlockKey = binding.GetExpression();
GateBlock gateBlock = null;
}
GateBlock gateBlock;
Set<ConditionBinding> bindings = ConditionBinding.Copy(conditionContext);
Dictionary<IExpression, GateBlock> blockMap;
if (!gateBlocks.TryGetValue(bindings, out blockMap))
@ -220,34 +224,22 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
GateBlock gateBlockOfVar = context.InputAttributes.Get<GateBlock>(ivd);
if (gateBlockOfVar == currentBlock) return; // local variable of the gateBlock
ExpressionWithBindings eb = new ExpressionWithBindings();
eb.Expression = ReplaceLocalIndices(currentBlock, expr);
List<ConditionBinding> bindings = FilterConditionContext(currentBlock, conditionContext);
if (bindings.Count > 0) eb.Bindings.Add(bindings);
//eb.Containers = Containers.InsideOf(context, GetAncestorIndexOfGateBlock(currentBlock));
ExpressionWithBindings eb = new ExpressionWithBindings(ReplaceLocalIndices(currentBlock, expr), FilterConditionContext(currentBlock));
if (isDef)
{
ExpressionWithBindings eb2;
if (!currentBlock.variablesDefined.TryGetValue(ivd, out eb2))
{
currentBlock.variablesDefined[ivd] = eb;
}
else
if (currentBlock.variablesDefined.TryGetValue(ivd, out ExpressionWithBindings eb2))
{
// all definitions of the same variable must have a common parent
currentBlock.variablesDefined[ivd] = GetCommonParent(eb, eb2);
}
else
{
currentBlock.variablesDefined[ivd] = eb;
}
}
else
{
List<ExpressionWithBindings> ebs;
if (!currentBlock.variablesUsed.TryGetValue(ivd, out ebs))
{
ebs = new List<ExpressionWithBindings>();
ebs.Add(eb);
currentBlock.variablesUsed[ivd] = ebs;
}
else
if (currentBlock.variablesUsed.TryGetValue(ivd, out List<ExpressionWithBindings> ebs))
{
// collect all uses that overlap with eb, and replace with their common parent
List<ExpressionWithBindings> notOverlapping = new List<ExpressionWithBindings>();
@ -255,8 +247,10 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
foreach (ExpressionWithBindings eb2 in ebs)
{
ExpressionWithBindings parent = GetCommonParent(eb, eb2);
if (CouldOverlap(eb, eb2)) eb = parent;
if (CouldOverlap(eb, eb2, ignoreBindings: GateTransform.DeterministicEnterExit))
{
eb = GetCommonParent(eb, eb2);
}
else notOverlapping.Add(eb2);
}
if (notOverlapping.Count == ebs.Count) break; // nothing overlaps
@ -268,6 +262,19 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
ebs.Add(eb);
currentBlock.variablesUsed[ivd] = ebs;
}
else
{
currentBlock.variablesUsed[ivd] = new List<ExpressionWithBindings> { eb };
}
}
List<ConditionBinding> FilterConditionContext(GateBlock gateBlock)
{
return conditionContext
.Where(binding => !CodeRecognizer.IsStochastic(context, binding.lhs) &&
!ContainsLocalVars(gateBlock, binding.lhs) &&
!ContainsLocalVars(gateBlock, binding.rhs))
.ToList();
}
}
@ -514,15 +521,6 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
return -1;
}
private List<ConditionBinding> FilterConditionContext(GateBlock gateBlock, List<ConditionBinding> conditionContext)
{
return conditionContext
.Where(binding => !CodeRecognizer.IsStochastic(context, binding.lhs) &&
!ContainsLocalVars(gateBlock, binding.lhs) &&
!ContainsLocalVars(gateBlock, binding.rhs))
.ToList();
}
/// <summary>
/// Use wildcards to replace any indices in expr which involve local variables of the gateBlock
/// </summary>
@ -600,12 +598,12 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
throw new Exception("This function should never be called");
}
internal static bool CouldOverlap(ExpressionWithBindings eb1, ExpressionWithBindings eb2)
internal static bool CouldOverlap(ExpressionWithBindings eb1, ExpressionWithBindings eb2, bool ignoreBindings = false)
{
var emptyBindings = (IEnumerable<IReadOnlyCollection<ConditionBinding>>)new[] { new ConditionBinding[0] };
IEnumerable<IReadOnlyCollection<ConditionBinding>> bindings1 = (eb1.Bindings.Count > 0) ?
IEnumerable<IReadOnlyCollection<ConditionBinding>> bindings1 = (eb1.Bindings.Count > 0 && !ignoreBindings) ?
eb1.Bindings : emptyBindings;
IEnumerable<IReadOnlyCollection<ConditionBinding>> bindings2 = (eb2.Bindings.Count > 0) ?
IEnumerable<IReadOnlyCollection<ConditionBinding>> bindings2 = (eb2.Bindings.Count > 0 && !ignoreBindings) ?
eb2.Bindings : emptyBindings;
foreach (IReadOnlyCollection<ConditionBinding> binding1 in bindings1)
{
@ -673,14 +671,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
}
else throw new Exception("Unhandled expression type: " + prefix1);
}
ExpressionWithBindings result = new ExpressionWithBindings();
result.Expression = parent;
if (eb1.Bindings.Count > 0 && eb2.Bindings.Count > 0)
{
result.Bindings.AddRange(eb1.Bindings);
result.Bindings.AddRange(eb2.Bindings);
}
return result;
return new ExpressionWithBindings(parent, eb1.Bindings, eb2.Bindings);
// Returns an expression equal to expr1 and expr2 under their respective bindings, or null if the expressions are not equal.
IExpression Unify(
@ -794,6 +785,23 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// </summary>
public Set<IReadOnlyCollection<ConditionBinding>> Bindings = new Set<IReadOnlyCollection<ConditionBinding>>(new EnumerableComparer<ConditionBinding>());
public ExpressionWithBindings(IExpression expression, IReadOnlyCollection<ConditionBinding> bindings)
{
this.Expression = expression;
if (bindings.Count > 0)
this.Bindings.Add(bindings);
}
public ExpressionWithBindings(IExpression expression, IReadOnlyCollection<IReadOnlyCollection<ConditionBinding>> bindings1, IReadOnlyCollection<IReadOnlyCollection<ConditionBinding>> bindings2)
{
this.Expression = expression;
if (bindings1.Count > 0 && bindings2.Count > 0)
{
this.Bindings.AddRange(bindings1);
this.Bindings.AddRange(bindings2);
}
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();

Просмотреть файл

@ -4,17 +4,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ML.Probabilistic.Compiler.Attributes;
using Microsoft.ML.Probabilistic.Compiler;
using Microsoft.ML.Probabilistic.Factors;
using Microsoft.ML.Probabilistic.Compiler.CodeModel;
using Microsoft.ML.Probabilistic.Collections;
using Microsoft.ML.Probabilistic.Utilities;
using System.Linq;
using System.Text;
using Microsoft.ML.Probabilistic.Algorithms;
using Microsoft.ML.Probabilistic.Collections;
using Microsoft.ML.Probabilistic.Compiler.Attributes;
using Microsoft.ML.Probabilistic.Compiler.CodeModel;
using Microsoft.ML.Probabilistic.Factors;
using Microsoft.ML.Probabilistic.Models.Attributes;
using Microsoft.ML.Probabilistic.Models;
using Microsoft.ML.Probabilistic.Utilities;
namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
@ -42,6 +41,8 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
get { return "GateTransform"; }
}
internal static readonly bool DeterministicEnterExit;
public override ITypeDeclaration Transform(ITypeDeclaration itd)
{
GateAnalysisTransform analysis = new GateAnalysisTransform();
@ -65,7 +66,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
PostProcess();
}
internal void PostProcess()
private void PostProcess()
{
foreach (Dictionary<IExpression, ConditionInformation> entry in condDict.Values)
{
@ -147,8 +148,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
Set<ConditionBinding> conditionCaseContext = new Set<ConditionBinding>();
conditionCaseContext.AddRange(bindings);
IForStatement loop = null;
ConditionBinding binding = GetConditionBinding(ics.Condition, context, out loop);
ConditionBinding binding = GetConditionBinding(ics.Condition, context, out IForStatement loop);
IExpression caseValue = binding.rhs;
if (!IsLiteralOrLoopVar(context, caseValue, out loop))
{
@ -162,10 +162,10 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
if (caseValue.GetExpressionType().Equals(typeof(bool)))
{
isBinaryCondition = true;
if (caseValue is ILiteralExpression)
if (caseValue is ILiteralExpression ile)
{
bool value = (bool) ((ILiteralExpression) caseValue).Value;
caseNumber = value ? Builder.LiteralExpr(0) : Builder.LiteralExpr(1);
bool value = (bool) ile.Value;
caseNumber = Builder.LiteralExpr(value ? 0 : 1);
}
else
throw new Exception($"Can\'t compute {nameof(caseNumber)} of {nameof(caseValue)}={caseValue}");
@ -178,7 +178,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
IExpression conditionLhs = binding.lhs;
IExpression transformedLhs = ConvertExpression(conditionLhs);
IExpression gateBlockKey = isStochastic ? binding.lhs : ics.Condition;
IExpression gateBlockKey = isStochastic || DeterministicEnterExit ? binding.lhs : ics.Condition;
if (isStochastic)
{
IVariableDeclaration missingLoopVar = GetMissingLoopVar(conditionCaseContext, ics.Condition);
@ -212,8 +212,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
bindings.Add(binding);
if (!isBinaryCondition)
Error($"Else clause not allowed for integer condition: {ics.Condition}.");
ILiteralExpression ile = caseNumber as ILiteralExpression;
if (ile == null)
if (!(caseNumber is ILiteralExpression ile))
{
Error($"Else clause not allowed for non-literal condition: {ics.Condition}.");
return ics;
@ -265,9 +264,13 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
context.AddStatementsBeforeCurrent(tempBlock.Statements);
}
private ConditionInformation GetConditionInfo(Set<ConditionBinding> conditionCaseContext,
private ConditionInformation GetConditionInfo(
Set<ConditionBinding> conditionCaseContext,
IConditionStatement conditionStmt,
IExpression conditionLhs, IExpression transformedLhs, IExpression gateBlockKey, bool isBinaryCondition,
IExpression conditionLhs,
IExpression transformedLhs,
IExpression gateBlockKey,
bool isBinaryCondition,
IForStatement loop)
{
//if (!context.OutputAttributes.Has<Stochastic>(condvd)) Error("Conditions must be stochastic, was : " + condition);
@ -281,18 +284,18 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
bool isStochastic = CodeRecognizer.IsStochastic(context, conditionLhs);
var gateBlock = context.InputAttributes.Get<GateBlock>(conditionStmt);
IExpression numberOfCases =
isStochastic ? GetNumberOfCases(conditionLhs, isBinaryCondition, loop, gateBlock) : null;
IExpression numberOfCases = GetNumberOfCases(conditionLhs, isBinaryCondition, loop, gateBlock);
ConditionInformation parent =
(conditionContext.Count == 0) ? null : conditionContext[conditionContext.Count - 1];
conditionInfo = new ConditionInformation(algorithm, conditionLhs, numberOfCases);
conditionInfo.gateBlock = gateBlock;
conditionInfo.parent = parent;
conditionInfo.isStochastic = isStochastic;
conditionInfo = new ConditionInformation(algorithm, conditionLhs, numberOfCases)
{
gateBlock = gateBlock,
parent = parent,
isStochastic = isStochastic,
conditionStmt = conditionStmt,
switchLoop = loop
};
dict[gateBlockKey] = conditionInfo;
// must set these before Build
conditionInfo.conditionStmt = conditionStmt;
conditionInfo.switchLoop = loop;
IVariableDeclaration conditionVar = Recognizer.GetVariableDeclaration(transformedLhs);
if (isStochastic)
{
@ -325,7 +328,10 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
return conditionInfo;
}
private IExpression GetNumberOfCases(IExpression expr, bool isBinaryCondition, IForStatement loop,
private IExpression GetNumberOfCases(
IExpression expr,
bool isBinaryCondition,
IForStatement loop,
GateBlock gateBlock)
{
if (isBinaryCondition)
@ -484,7 +490,11 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// For example, if expr = a[0,j][1,k] and the gateBlock has a pattern a[*,j][*,k] then this function
/// returns clone[0][1][caseNumber].
/// </remarks>
internal IExpression ReplaceWithClone(IExpression expr, bool isDef, IVariableDeclaration ivd, int start,
internal IExpression ReplaceWithClone(
IExpression expr,
bool isDef,
IVariableDeclaration ivd,
int start,
int conditionContextIndex)
{
if (conditionContextIndex < start)
@ -498,11 +508,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
return expr;
}
ExpressionWithBindings eb = new ExpressionWithBindings()
{
Expression = expr,
Bindings = Set<IReadOnlyCollection<ConditionBinding>>.FromEnumerable(new[] {bindings}),
};
ExpressionWithBindings eb = new ExpressionWithBindings(expr, bindings);
if (ci.gateBlock.variablesDefined.TryGetValue(ivd, out var definedExpression) &&
GateAnalysisTransform.CouldOverlap(definedExpression, eb))
{
@ -824,7 +830,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
stmts.Add(Builder.ExprStatement(Builder.VarDeclExpr(casesVar)));
args.Add(Builder.VarRefExpr(casesVar));
}
IMethodInvokeExpression imie = Builder.StaticMethod(new Models.ActionOut2<bool, bool, bool>(Gate.CasesBool), args.ToArray());
IMethodInvokeExpression imie = Builder.StaticMethod(new ActionOut2<bool, bool, bool>(Gate.CasesBool), args.ToArray());
//context.OutputAttributes.Set(imie, new Stochastic()); // for IfCuttingTransform
stmts.Add(Builder.ExprStatement(imie));
}
@ -887,12 +893,19 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// <param name="conditionContextIndex">An index into the conditionContext array.</param>
/// <param name="isDef"></param>
/// <returns></returns>
internal IExpression GetClone(BasicTransformContext context, ExpressionWithBindings eb, ICollection<ConditionBinding> currentBindings, GateTransform transform, int start, int conditionContextIndex, bool isDef)
internal IExpression GetClone(
BasicTransformContext context,
ExpressionWithBindings eb,
ICollection<ConditionBinding> currentBindings,
GateTransform transform,
int start,
int conditionContextIndex,
bool isDef)
{
IExpression expr = eb.Expression;
// expr should not contain the conditionLhs
if (Builder.ContainsExpression(expr, conditionLhs))
context.Error($"Internal: expr ({expr}) contains the conditionLhs ({conditionLhs})");
//if (Builder.ContainsExpression(expr, conditionLhs))
// context.Error($"Internal: expr ({expr}) contains the conditionLhs ({conditionLhs})");
ClonedVarInfo cvi = GetClonedVarInfo(context, eb, isDef);
if (cvi == null)
{
@ -901,7 +914,8 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
if (cvi.arrayDecl == null)
{
var extraBindings = IndexingTransform.FilterBindingSet(eb.Bindings,
binding => !currentBindings.Contains(binding) && !CodeRecognizer.IsStochastic(context, binding.lhs)
binding => (GateTransform.DeterministicEnterExit || !currentBindings.Contains(binding)) &&
!CodeRecognizer.IsStochastic(context, binding.lhs)
);
CreateCloneArray(cvi, context, transform, start, conditionContextIndex, extraBindings);
}
@ -920,7 +934,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
context.Error($"Could not determine type of expression: {expr}");
return null;
}
cvi = new ClonedVarInfo(expr, exprType, isDef);
cvi = new ClonedVarInfo(expr, exprType, isDef, eb.Bindings.Count);
cloneMap[eb] = cvi;
return cvi;
}
@ -930,10 +944,9 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// </summary>
/// <param name="context"></param>
/// <param name="expr"></param>
/// <param name="indices"></param>
///
/// <param name="indices">Modified</param>
/// <returns></returns>
public IExpression ReplaceAnyItem(BasicTransformContext context, IExpression expr, List<IList<IExpression>> indices)
private IExpression ReplaceAnyItem(BasicTransformContext context, IExpression expr, List<IList<IExpression>> indices)
{
if (expr is IArrayIndexerExpression iaie)
{
@ -945,7 +958,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
IExpression index = iaie.Indices[i];
if (Recognizer.IsStaticMethod(index, new Func<int>(GateAnalysisTransform.AnyIndex)))
{
IExpression newIndex = GetIndexVar(context, result, i);
IExpression newIndex = GetIndexVar(result, i);
newIndices.Add(newIndex);
allIndices.Add(newIndex);
}
@ -955,25 +968,25 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
return Builder.ArrayIndex(result, allIndices);
}
else return expr;
}
public IVariableReferenceExpression GetIndexVar(BasicTransformContext context, IExpression expr, int i)
{
IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(expr);
if (ivd == null) throw new Exception($"Could not get variable declaration for {expr}");
VariableInformation vi = VariableInformation.GetVariableInformation(context, ivd);
int d = Recognizer.GetIndexingDepth(expr);
while (vi.indexVars.Count <= d)
IVariableReferenceExpression GetIndexVar(IExpression result, int i)
{
vi.indexVars.Add(new IVariableDeclaration[vi.sizes[vi.indexVars.Count].Length]);
IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(result);
if (ivd == null) throw new Exception($"Could not get variable declaration for {result}");
VariableInformation vi = VariableInformation.GetVariableInformation(context, ivd);
int d = Recognizer.GetIndexingDepth(result);
while (vi.indexVars.Count <= d)
{
vi.indexVars.Add(new IVariableDeclaration[vi.sizes[vi.indexVars.Count].Length]);
}
IVariableDeclaration v = vi.indexVars[d][i];
if (v == null || Recognizer.GetLoopForVariable(context, v, conditionStmt) != null)
{
v = VariableInformation.GenerateLoopVar(context, "_gi");
if (vi.indexVars[d][i] == null) vi.indexVars[d][i] = v;
}
return Builder.VarRefExpr(v);
}
IVariableDeclaration v = vi.indexVars[d][i];
if (v == null || Recognizer.GetLoopForVariable(context, v, conditionStmt) != null)
{
v = VariableInformation.GenerateLoopVar(context, "_gi");
if (vi.indexVars[d][i] == null) vi.indexVars[d][i] = v;
}
return Builder.VarRefExpr(v);
}
/// <summary>
@ -983,18 +996,23 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// <param name="context"></param>
/// <param name="transform"></param>
/// <param name="start"></param>
/// <param name="bindingSet"></param>
/// <param name="bindingSet">Bindings used to construct containers in which the clone array (and elements thereof) are declared.</param>
/// <param name="conditionContextIndex">An index into the conditionContext array.</param>
/// <returns></returns>
private void CreateCloneArray(ClonedVarInfo cvi, BasicTransformContext context, GateTransform transform, int start, int conditionContextIndex,
Set<IReadOnlyCollection<ConditionBinding>> bindingSet)
private void CreateCloneArray(
ClonedVarInfo cvi,
BasicTransformContext context,
GateTransform transform,
int start,
int conditionContextIndex,
Set<IReadOnlyCollection<ConditionBinding>> bindingSet)
{
IExpression expr = cvi.expr;
Type exprType = cvi.exprType;
bool isExitVar = cvi.IsExitVar;
IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(expr);
// this statement fills in cvi.indices
// this statement fills in cvi.wildcardVars
IExpression indexedExpr = ReplaceAnyItem(context, expr, cvi.wildcardVars);
IExpression transformedExpr;
IVariableDeclaration transformedVar;
@ -1012,13 +1030,15 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
bool isIndexedByCondition = (isSwitch && Builder.ContainsExpression(expr, caseNumber));
// construct cvi.containers from eb.Bindings
// change keptContainers to be a single conditional stmt containing all bindings
// caseVars must have the same conditional stmt
// if cloning outside the loop, must treat the loop variable as a local variable and exclude it from conditions
bool cloneOutsideLoop = (isSwitch && !isIndexedByCondition);
IStatement bindingContainer = IndexingTransform.GetBindingSetContainer(IndexingTransform.FilterBindingSet(bindingSet,
binding => !cloneOutsideLoop || !Builder.ContainsExpression(binding.GetExpression(), caseNumber)));
binding => !(cloneOutsideLoop && Builder.ContainsExpression(binding.GetExpression(), caseNumber))));
if (bindingContainer != null) cvi.containers.Add(bindingContainer);
if (!isStochastic)
if (!isStochastic && !GateTransform.DeterministicEnterExit)
{
cvi.arrayDecl = transformedVar;
cvi.arrayRef = transformedExpr; //indexedExpr;
@ -1033,17 +1053,16 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// An array of all the uses of this variable in each case
IExpression arraySize;
if (isExitVar) arraySize = numberOfCases; // exit variables must be defined in all cases of the condition.
if (!isStochastic) arraySize = null;
else if (isExitVar) arraySize = numberOfCases; // exit variables must be defined in all cases of the condition.
else if (isIndexedByCondition) arraySize = null; // used in exactly one case.
else if (isFixedSize) arraySize = cvi.caseCount; // used in some cases.
else arraySize = numberOfCases; // used in all cases.
cvi.IsEnterOne = (arraySize == null);
cvi.IsEnterOne = !isExitVar && isIndexedByCondition;
List<IStatement> stBefore = new List<IStatement>();
VariableInformation vi = VariableInformation.GetVariableInformation(context, ivd);
List<IList<IExpression>> exprIndices = Recognizer.GetIndices(expr);
IList<IStatement> stBefore = Builder.StmtCollection();
IList<IStatement> stAfter = Builder.StmtCollection();
string name = ToString(transformedExpr);
name = vi.Name + "_";
foreach (IList<IExpression> bracket in exprIndices)
@ -1067,7 +1086,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
IVariableDeclaration[][] indexVars = new IVariableDeclaration[][] { new[] { indexVar } };
// Cannot set useLiteralIndices=true because arraySize is initially zero and gets incremented later.
cvi.arrayDecl = vi.DeriveArrayVariable(stBefore, context,
name, arraySizes, indexVars, exprIndices, cvi.wildcardVars, useArrays: true);
name, arraySizes, indexVars, exprIndices, cvi.wildcardVars, useArrays: true);
context.InputAttributes.Remove<ConditionInformation>(cvi.arrayDecl);
context.InputAttributes.Set(cvi.arrayDecl, this);
if (!context.InputAttributes.Has<DerivedVariable>(cvi.arrayDecl))
@ -1080,10 +1099,10 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
if (isExitVar)
{
// *************** Gate Exit case ***********************
if (isFixedSize)
if (isFixedSize /*&& isStochastic*/)
{
// keep track of which cases the variable is defined in.
IArrayCreateExpression ace = Builder.ArrayCreateExpr(typeof (int), arraySize);
IArrayCreateExpression ace = Builder.ArrayCreateExpr(typeof (int), cvi.caseCount);
ace.Initializer = Builder.BlockExpr();
cvi.caseNumbers = ace;
}
@ -1105,7 +1124,11 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// TODO: insert argument types
Delegate d;
IExpression exitMethod;
if (casesArray == null)
if (!isStochastic)
{
exitMethod = Builder.StaticGenericMethod(new Func<PlaceHolder, PlaceHolder>(Clone.Copy), new Type[] { exprType }, arrayRef);
}
else if (casesArray == null)
{
if (useExitRandom)
{
@ -1137,7 +1160,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
IStatement exit = Builder.AssignStmt(transformedExpr, exitMethod);
exit = Containers.WrapWithContainers(exit, wildcardLoops);
stAfter.Add(exit);
cvi.exitStatements = new List<IStatement>() { exit };
if (!useExitRandom && !context.InputAttributes.Has<DerivedVariable>(transformedVar))
context.OutputAttributes.Set(transformedVar, new DerivedVariable());
}
@ -1151,7 +1174,11 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// 4. Therefore can use EnterOne to enter this variable.
IExpression enterMethod;
Type selectorType = selector.GetExpressionType();
if (isIndexedByCondition)
if (!isStochastic)
{
enterMethod = Builder.StaticGenericMethod(new Func<PlaceHolder, PlaceHolder>(Clone.Copy), new Type[] { exprType }, transformedExpr);
}
else if (isIndexedByCondition)
{
// used in exactly one case.
enterMethod = Builder.StaticGenericMethod(new Func<int, PlaceHolder, int, PlaceHolder>(Gate.EnterOne),
@ -1225,26 +1252,30 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
stBefore.Add(enter);
}
var stBeforeWrapped = Containers.WrapWithContainers(stBefore, cvi.containers);
int conditionStmtIndex = context.GetAncestorIndex(conditionStmt);
// change keptContainers to be a single conditional stmt containing all bindings
// caseVars must have the same conditional stmt
stBefore = Containers.WrapWithContainers(stBefore, cvi.containers);
stAfter = Containers.WrapWithContainers(stAfter, cvi.containers);
int ancIndex = cloneOutsideLoop ? context.GetAncestorIndex(switchLoop) : conditionStmtIndex;
if (!isExitVar && isIndexedByCondition)
if (cvi.IsEnterOne)
{
// define the clone array inside the condition statement.
// this is required when each array element can be used more than once.
AddCloneStatements(context, stBefore);
Assert.IsTrue(stAfter.Count == 0);
AddCloneStatements(context, stBeforeWrapped);
Assert.IsTrue(cvi.exitStatements == null);
}
else
{
// this is required for exit vars and for switch enter vars that are not indexed by the switch loop.
// otherwise, this is only an optimization. if each array element will be used once, then we know that the evidence message will be uniform,
// so we can place the declaration of the clone array outside the condition statement.
context.AddStatementsBeforeAncestorIndex(ancIndex, stBefore, false);
context.AddStatementsAfterAncestorIndex(ancIndex, stAfter, false);
context.AddStatementsBeforeAncestorIndex(ancIndex, stBeforeWrapped, false);
if ((cloneOutsideLoop || true) && cvi.exitStatements != null)
{
var exitStatementsWrapped = Containers.WrapWithContainers(cvi.exitStatements, cvi.containers);
context.AddStatementsAfterAncestorIndex(ancIndex, exitStatementsWrapped, false);
cvi.exitStatements = null;
}
// When isExitVar and not a switch statement, GetCloneForCase will add the exit statements after the last condition statement.
// This ensures that the exit statement follows all of the definitions of the exiting variable.
}
}
@ -1415,7 +1446,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// <summary>
/// Type of expr.
/// </summary>
internal Type exprType;
internal readonly Type exprType;
/// <summary>
/// Loop indices corresponding to the wildcards in expr.
@ -1442,7 +1473,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// <summary>
/// A map from case numbers to clone variables.
/// </summary>
internal Dictionary<IExpression, IVariableDeclaration> caseVars = new Dictionary<IExpression, IVariableDeclaration>();
internal readonly Dictionary<IExpression, IVariableDeclaration> caseVars = new Dictionary<IExpression, IVariableDeclaration>();
/// <summary>
/// An array of integers, listing the condition branches in which the variable is used.
@ -1456,7 +1487,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// <summary>
/// The length of caseNumbers.
/// </summary>
internal ILiteralExpression caseCount;
internal readonly ILiteralExpression caseCount;
/// <summary>
/// The number of distinct cases in which this variable is defined.
@ -1466,14 +1497,16 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
/// <summary>
/// Containers in which the clone array (and elements thereof) are declared.
/// </summary>
internal List<IStatement> containers = new List<IStatement>();
internal readonly List<IStatement> containers = new List<IStatement>();
internal ClonedVarInfo(IExpression expr, Type exprType, bool isDef)
internal IList<IStatement> exitStatements;
internal ClonedVarInfo(IExpression expr, Type exprType, bool isDef, int caseCount)
{
this.expr = expr;
this.exprType = exprType;
IsExitVar = isDef;
caseCount = Builder.LiteralExpr(0); // will be mutated later in cvi.AddCase
this.caseCount = Builder.LiteralExpr(caseCount); // will be mutated later in cvi.AddCase
}
/// <summary>
@ -1495,18 +1528,19 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
return Builder.VarRefExpr(arrayDecl);
}
IExpression item;
if (condInfo.isStochastic)
if (GateTransform.DeterministicEnterExit || condInfo.isStochastic)
{
// for a switch/default statement, caseNumber is the loop index,
// and AddCase returns -1.
int index = AddCase(isDef, caseNumber);
// when expr is a use of an EnterPartial variable, use the count as the index, otherwise use the case number.
IExpression indexExpr = (index == -1 || IsExitVar) ? caseNumber : Builder.LiteralExpr(index);
List<IList<IExpression>> indices2 = new List<IList<IExpression>>();
indices2.AddRange(wildcardVars);
IList<IExpression> lastIndex = Builder.ExprCollection();
lastIndex.Add(indexExpr);
indices2.Add(lastIndex);
int index = AddCase(isDef, caseNumber);
if (condInfo.isStochastic)
{
// when expr is a use of an EnterPartial variable, use the count as the index, otherwise use the case number.
IExpression indexExpr = (index == -1 || IsExitVar) ? caseNumber : Builder.LiteralExpr(index);
IList<IExpression> lastIndex = Builder.ExprCollection();
lastIndex.Add(indexExpr);
indices2.Add(lastIndex);
}
item = Builder.JaggedArrayIndex(arrayRef, indices2);
}
else
@ -1567,24 +1601,30 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// so we might benefit from caching them
List<IStatement> wildcardLoops = VariableInformation.GetVariableInformation(context, caseVar).BuildWildcardLoops(wildcardVars);
assignSt = Containers.WrapWithContainers(assignSt, wildcardLoops);
if (!isDef)
{
stmts.Add(assignSt);
}
else
if (isDef)
{
assignSt = Containers.WrapWithContainers(assignSt, containers);
int conditionStmtIndex = context.GetAncestorIndex(condInfo.conditionStmt);
if (exitStatements != null && IsDefinedInAllCases())
{
var exitStatementsWrapped = Containers.WrapWithContainers(exitStatements, containers);
context.AddStatementsAfterAncestorIndex(conditionStmtIndex, exitStatementsWrapped, false);
}
conditionStmtIndex += 2;
context.AddStatementAfterAncestorIndex(conditionStmtIndex, assignSt);
}
else
{
stmts.Add(assignSt);
}
stmts = Containers.WrapWithContainers(stmts, containers);
condInfo.AddCloneStatements(context, stmts);
return Builder.VarRefExpr(caseVar);
}
/// <summary>
/// Given a case number, get an index into the clones array.
/// Given a case number, get an index into the clones array.
/// For a switch/default statement, caseNumber is the loop index, and AddCase returns -1.
/// </summary>
/// <param name="isDef">True if the expression to be cloned is on the lhs of an assignment.</param>
/// <param name="caseNumber"></param>

Просмотреть файл

@ -427,8 +427,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
protected override IExpression ConvertArrayIndexer(IArrayIndexerExpression iaie)
{
IExpression target;
var indices = Recognizer.GetIndices(iaie, out target);
var indices = Recognizer.GetIndices(iaie, out IExpression target);
if (target is IVariableReferenceExpression)
{
// Only convert indices that could matter.
@ -479,11 +478,9 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
}
foreach (var arg in imie.Arguments)
{
if (arg is IAddressOutExpression)
if (arg is IAddressOutExpression iaoe)
{
IAddressOutExpression iaoe = (IAddressOutExpression)arg;
IExpression target;
var indices = Recognizer.GetIndices(iaoe.Expression, out target);
var indices = Recognizer.GetIndices(iaoe.Expression, out IExpression target);
if (target is IVariableReferenceExpression || target is IVariableDeclarationExpression)
{
IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(target);
@ -547,8 +544,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
IMethodInvokeExpression imie = (IMethodInvokeExpression)iae.Expression;
var sourceExpr = imie.Arguments[1];
IExpression source;
var sourceIndices = Recognizer.GetIndices(sourceExpr, out source);
var sourceIndices = Recognizer.GetIndices(sourceExpr, out IExpression source);
if (source is IVariableDeclaration)
{
IVariableDeclaration sourceVar = Recognizer.GetVariableDeclaration(source);

Просмотреть файл

@ -6,9 +6,9 @@ using System.Collections.Generic;
using System.Text;
using System.Linq;
using Microsoft.ML.Probabilistic.Compiler.Attributes;
using Microsoft.ML.Probabilistic.Compiler;
using Microsoft.ML.Probabilistic.Compiler.CodeModel;
using Microsoft.ML.Probabilistic.Collections;
using Microsoft.ML.Probabilistic.Utilities;
namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
@ -55,7 +55,16 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
StringBuilder sb = new StringBuilder("IndexInfo");
sb.Append("(");
sb.Append(count);
sb.AppendLine(")");
sb.Append(")");
foreach (IReadOnlyCollection<ConditionBinding> binding in bindings)
{
if (binding.Count > 0)
{
sb.Append(" (");
sb.Append(StringUtil.CollectionToString(binding, ","));
sb.Append(")");
}
}
sb.Append(" containers = ");
sb.AppendLine(containers.ToString());
return sb.ToString();
@ -104,9 +113,8 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
var indices = Recognizer.GetIndices(iaie);
bool allLoopIndices = indices.All(bracket => bracket.All(indexExpr =>
{
if (indexExpr is IVariableReferenceExpression)
if (indexExpr is IVariableReferenceExpression ivre)
{
IVariableReferenceExpression ivre = (IVariableReferenceExpression)indexExpr;
return (Recognizer.GetLoopForVariable(context, ivre) != null);
}
else
@ -124,40 +132,35 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
info.IsAssignedTo = isDef;
indexInfoOf[iaie] = info;
return iaie;
}
internal static List<ConditionBinding> GetBindings(BasicTransformContext context, IEnumerable<IStatement> containers)
{
List<ConditionBinding> bindings = new List<ConditionBinding>();
foreach (IStatement st in containers)
List<ConditionBinding> GetBindings(BasicTransformContext context, IEnumerable<IStatement> containers)
{
if (st is IConditionStatement)
List<ConditionBinding> bindings = new List<ConditionBinding>();
foreach (IStatement st in containers)
{
IConditionStatement ics = (IConditionStatement) st;
if (!CodeRecognizer.IsStochastic(context, ics.Condition))
if (st is IConditionStatement ics)
{
ConditionBinding binding = new ConditionBinding(ics.Condition);
bindings.Add(binding);
if (!CodeRecognizer.IsStochastic(context, ics.Condition))
{
ConditionBinding binding = new ConditionBinding(ics.Condition);
bindings.Add(binding);
}
}
}
return bindings;
}
return bindings;
}
/// <summary>
/// Raise an error if any expression is stochastic.
/// </summary>
/// <param name="exprs"></param>
private void CheckIndicesAreNotStochastic(IList<IExpression> exprs)
{
foreach (IExpression index in exprs)
void CheckIndicesAreNotStochastic(IList<IExpression> exprs)
{
foreach (var ivd in Recognizer.GetVariables(index))
foreach (IExpression index in exprs)
{
if (CodeRecognizer.IsStochastic(context, ivd))
foreach (var ivd in Recognizer.GetVariables(index))
{
string msg = "Indexing by a random variable '" + ivd.Name + "'. You must wrap this statement with Variable.Switch(" + index + ")";
Error(msg);
if (CodeRecognizer.IsStochastic(context, ivd))
{
string msg = "Indexing by a random variable '" + ivd.Name + "'. You must wrap this statement with Variable.Switch(" + index + ")";
Error(msg);
}
}
}
}

Просмотреть файл

@ -687,15 +687,13 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
for (int i = 0; i < containers.inputs.Count; i++)
{
IStatement container = containers.inputs[i];
if (container is IForStatement)
if (container is IForStatement ifs)
{
IForStatement ifs = container as IForStatement;
if (Builder.ContainsExpression(ifs.Condition, expr))
continue;
}
else if (container is IConditionStatement)
else if (container is IConditionStatement ics)
{
IConditionStatement ics = (IConditionStatement)container;
if (Builder.ContainsExpression(ics.Condition, expr))
continue;
}

Просмотреть файл

@ -895,11 +895,11 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
string msgText = msg.ToString();
// Look for TraceMessages attribute that matches this message
var trace = context.InputAttributes.Get<TraceMessages>(channelDecl);
var trace = channelDecl is null ? null : context.InputAttributes.Get<TraceMessages>(channelDecl);
if (trace != null && trace.Containing != null && !msgText.Contains(trace.Containing)) trace = null;
// Look for ListenToMessages attribute that matches this message
var listenTo = context.InputAttributes.Get<ListenToMessages>(channelDecl);
var listenTo = channelDecl is null ? null : context.InputAttributes.Get<ListenToMessages>(channelDecl);
if (listenTo != null && listenTo.Containing != null && !msgText.Contains(listenTo.Containing)) listenTo = null;

Просмотреть файл

@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.ML.Probabilistic.Compiler;
using Microsoft.ML.Probabilistic.Compiler.CodeModel;
using Microsoft.ML.Probabilistic.Factors;
@ -13,6 +12,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
/// <summary>
/// Attach ForwardPointMass attributes to variables. Must be done after GateTransform and before MessageTransform.
/// Assumes that each use of a variable follows the definitions that reach it.
/// </summary>
internal class PointMassAnalysisTransform : ShallowCopyTransform
{
@ -52,11 +52,30 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
}
}
protected override IExpression ConvertAssign(IAssignExpression iae)
{
// if all args to a deterministic method are non-stoch or ForwardPointMass, the output is ForwardPointMass
IVariableDeclaration targetVar = Recognizer.GetVariableDeclaration(iae.Target);
if (targetVar == null || variablesDefinedNonPointMass.Contains(targetVar))
return base.ConvertAssign(iae);
ProcessDefinition(iae.Expression, targetVar, isLhs: true);
return base.ConvertAssign(iae);
}
protected override IExpression ConvertAddressOut(IAddressOutExpression iaoe)
{
IVariableDeclaration targetVar = Recognizer.GetVariableDeclaration(iaoe.Expression);
if (targetVar == null || variablesDefinedNonPointMass.Contains(targetVar))
return base.ConvertAddressOut(iaoe);
IMethodInvokeExpression imie = context.FindAncestor<IMethodInvokeExpression>();
ProcessDefinition(imie, targetVar, isLhs: false);
return base.ConvertAddressOut(iaoe);
}
protected void ProcessDefinition(IExpression expr, IVariableDeclaration targetVar, bool isLhs)
{
bool targetIsPointMass = false;
IMethodInvokeExpression imie = expr as IMethodInvokeExpression;
if (imie != null)
if (expr is IMethodInvokeExpression imie)
{
// TODO: consider using a method attribute for this
if (Recognizer.IsStaticGenericMethod(imie, new Models.FuncOut<PlaceHolder, PlaceHolder, PlaceHolder>(Clone.VariablePoint))
@ -107,40 +126,20 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
context.OutputAttributes.Remove<ForwardPointMass>(targetVar);
}
}
}
private bool ArgumentIsPointMass(IExpression arg)
{
bool IsOut = (arg is IAddressOutExpression);
if (CodeRecognizer.IsStochastic(context, arg) && !IsOut)
bool ArgumentIsPointMass(IExpression arg)
{
IVariableDeclaration argVar = Recognizer.GetVariableDeclaration(arg);
return (argVar != null) && context.InputAttributes.Has<ForwardPointMass>(argVar);
bool IsOut = (arg is IAddressOutExpression);
if (CodeRecognizer.IsStochastic(context, arg) && !IsOut)
{
IVariableDeclaration argVar = Recognizer.GetVariableDeclaration(arg);
return (argVar != null) && context.InputAttributes.Has<ForwardPointMass>(argVar);
}
else
{
return true;
}
}
else
{
return true;
}
}
protected override IExpression ConvertAssign(IAssignExpression iae)
{
// if all args to a deterministic method are non-stoch or ForwardPointMass, the output is ForwardPointMass
IVariableDeclaration targetVar = Recognizer.GetVariableDeclaration(iae.Target);
if (targetVar == null || variablesDefinedNonPointMass.Contains(targetVar))
return base.ConvertAssign(iae);
ProcessDefinition(iae.Expression, targetVar, isLhs: true);
return base.ConvertAssign(iae);
}
protected override IExpression ConvertAddressOut(IAddressOutExpression iaoe)
{
IVariableDeclaration targetVar = Recognizer.GetVariableDeclaration(iaoe.Expression);
if (targetVar == null || variablesDefinedNonPointMass.Contains(targetVar))
return base.ConvertAddressOut(iaoe);
IMethodInvokeExpression imie = context.FindAncestor<IMethodInvokeExpression>();
ProcessDefinition(imie, targetVar, isLhs: false);
return base.ConvertAddressOut(iaoe);
}
}
}

Просмотреть файл

@ -621,8 +621,7 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
{
foreach (var target in newNodes[dg.dependencyGraph.TargetOf(edgeInDg)])
{
EdgeIndex edgeInG;
if (g.TryGetEdge(source, target, out edgeInG))
if (g.TryGetEdge(source, target, out int edgeInG))
{
action(edgeInG);
}
@ -2846,55 +2845,29 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
// increase the cost of reversing edges on offset cycles, since these will correspond to many more reversed edges in the unrolled graph.
private void UpdateCostsFromOffsetEdges(float[] edgeCost)
{
// collect the set of offset edges
Dictionary<NodeIndex, IndexedGraph> offsetEdgesInGroup = new Dictionary<EdgeIndex, IndexedGraph>();
foreach (NodeIndex source in dg.dependencyGraph.Nodes)
{
Set<NodeIndex> sourceGroups = null;
if (groupGraph != null)
sourceGroups = groupGraph.GetGroupSet(source);
foreach (EdgeIndex edge in dg.dependencyGraph.EdgesOutOf(source))
{
//if (IsAvailableOffsetEdge(edge)) // TODO: make this work
if (IsOffsetEdge(edge))
{
NodeIndex target = dg.dependencyGraph.TargetOf(edge);
NodeIndex sharedGroup = -1;
if (sourceGroups != null)
sharedGroup = groupGraph.GetSmallestGroup(target, sourceGroups.Contains);
IndexedGraph offsetGraph;
if (!offsetEdgesInGroup.TryGetValue(sharedGroup, out offsetGraph))
{
offsetGraph = new IndexedGraph(g.Nodes.Count);
offsetEdgesInGroup[sharedGroup] = offsetGraph;
}
offsetGraph.AddEdge(source, target);
}
}
}
Dictionary<int, IndexedGraph> offsetEdgesByGroup = GetOffsetEdgesByGroup();
// for each group, find all edges on a path from offset target to source
NodeIndex group = default(NodeIndex);
IndexedGraph deletedGraph = null;
NodeIndex group = default(NodeIndex); // modified prior to each search
IndexedGraph deletedGraph = null; // modified prior to each search
Set<EdgeIndex> edgesOnCycle = new Set<EdgeIndex>();
Set<NodeIndex> nodesOnCycle = new Set<EdgeIndex>();
DepthFirstSearch<NodeIndex> dfs = new DepthFirstSearch<NodeIndex>(node => TargetsInGroup(node, group, deletedGraph), g);
Action<Edge<NodeIndex>> finishEdge = delegate (Edge<NodeIndex> edge)
void finishEdge(Edge<NodeIndex> edge)
{
if (nodesOnCycle.Contains(edge.Target))
{
nodesOnCycle.Add(edge.Source);
EdgeIndex edge2;
if (g.TryGetEdge(edge.Source, edge.Target, out edge2))
if (g.TryGetEdge(edge.Source, edge.Target, out int edge2))
{
edgesOnCycle.Add(edge2);
}
}
};
}
dfs.FinishTreeEdge += finishEdge;
dfs.CrossEdge += finishEdge;
if (debug)
{
dfs.BackEdge += delegate (Edge<NodeIndex> edge)
void backEdge(Edge<NodeIndex> edge)
{
if (edge.Source != edge.Target && dg.mustNotInit.Contains(originalNode[edge.Source]))
{
@ -2915,34 +2888,37 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
Debug.WriteLine(NodeToString(node));
}
}
};
}
dfs.BackEdge += backEdge;
}
var onPath = MakeIndexedProperty.FromSet(edgesOnCycle);
NodeIndex sinkNode = default(NodeIndex);
NodeIndex sinkNode = default(NodeIndex); // modified prior to each search
var finder = new EdgeOnPathFinder<NodeIndex, EdgeIndex>(node => EdgesInGroup(node, group, deletedGraph),
g.TargetOf, g, onPath, node => (node == sinkNode));
foreach (var entry in offsetEdgesInGroup)
foreach (var entry in offsetEdgesByGroup)
{
deletedGraph = entry.Value;
group = entry.Key;
edgesOnCycle.Clear();
foreach (var deletedEdge in deletedGraph.Edges)
{
sinkNode = deletedGraph.SourceOf(deletedEdge);
NodeIndex sourceNode = deletedGraph.TargetOf(deletedEdge);
if (verbose)
Debug.WriteLine("UpdateCostsFromOffsetEdges searching from {0} to {1}", sourceNode, sinkNode);
// newMethod can be very slow for some graphs, so we leave the option of the old fast method.
bool newMethod = false;
if (newMethod)
{
if (verbose)
Debug.WriteLine("UpdateCostsFromOffsetEdges searching from {0}", deletedGraph.TargetOf(deletedEdge));
sinkNode = deletedGraph.SourceOf(deletedEdge);
finder.SearchFrom(deletedGraph.TargetOf(deletedEdge));
// This modifies onPath and therefore edgesOnCycle
finder.SearchFrom(sourceNode);
}
else
{
nodesOnCycle.Clear();
nodesOnCycle.Add(deletedGraph.SourceOf(deletedEdge));
nodesOnCycle.Add(sinkNode);
dfs.Clear();
dfs.SearchFrom(deletedGraph.TargetOf(deletedEdge));
dfs.SearchFrom(sourceNode);
}
}
foreach (var edge in edgesOnCycle)
@ -2952,6 +2928,37 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
Debug.WriteLine($"UpdateCostsFromOffsetEdges incrementing {EdgeToString(edge)}");
}
}
Dictionary<int, IndexedGraph> GetOffsetEdgesByGroup()
{
Dictionary<NodeIndex, IndexedGraph> offsetEdgesByGroup2 = new Dictionary<EdgeIndex, IndexedGraph>();
foreach (NodeIndex source in dg.dependencyGraph.Nodes)
{
Set<NodeIndex> sourceGroups = null;
if (groupGraph != null)
sourceGroups = groupGraph.GetGroupSet(source);
foreach (EdgeIndex edge in dg.dependencyGraph.EdgesOutOf(source))
{
//if (IsAvailableOffsetEdge(edge)) // TODO: make this work
if (IsOffsetEdge(edge))
{
NodeIndex target = dg.dependencyGraph.TargetOf(edge);
NodeIndex sharedGroup = -1;
if (sourceGroups != null)
sharedGroup = groupGraph.GetSmallestGroup(target, sourceGroups.Contains);
IndexedGraph offsetGraph;
if (!offsetEdgesByGroup2.TryGetValue(sharedGroup, out offsetGraph))
{
offsetGraph = new IndexedGraph(g.Nodes.Count);
offsetEdgesByGroup2[sharedGroup] = offsetGraph;
}
offsetGraph.AddEdge(source, target);
}
}
}
return offsetEdgesByGroup2;
}
}
// only used by UpdateCostsFromOffsetEdges
private IEnumerable<NodeIndex> TargetsInGroup(NodeIndex node, NodeIndex group, IDirectedGraph<NodeIndex> deletedGraph)
@ -2959,8 +2966,12 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
foreach (EdgeIndex edge in g.EdgesOutOf(node))
{
// do not traverse NoInit edges
if (IsNoInit(edge))
if (IsNoInit(edge) || !(IsRequired(edge, includeAny: true) || IsFreshEdge(edge)))
{
if (verbose)
Debug.WriteLine($"Blocked at {EdgeToString(edge)}");
continue;
}
NodeIndex target = g.TargetOf(edge);
if (groupGraph != null)
{
@ -2980,8 +2991,12 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
foreach (EdgeIndex edge in g.EdgesOutOf(node))
{
// do not traverse NoInit edges
if (IsNoInit(edge))
if (IsNoInit(edge) || !(IsRequired(edge, includeAny: true) || IsFreshEdge(edge)))
{
if (verbose)
Debug.WriteLine($"Blocked at {EdgeToString(edge)}");
continue;
}
NodeIndex target = g.TargetOf(edge);
var targetGroups = groupGraph.GetGroupSet(target);
if (targetGroups.Contains(group))
@ -2994,8 +3009,12 @@ namespace Microsoft.ML.Probabilistic.Compiler.Transforms
foreach (EdgeIndex edge in g.EdgesOutOf(target2))
{
// do not traverse NoInit edges
if (IsNoInit(edge))
if (IsNoInit(edge) || !(IsRequired(edge, includeAny: true) || IsFreshEdge(edge)))
{
if (verbose)
Debug.WriteLine($"Blocked at {EdgeToString(edge)}");
continue;
}
NodeIndex target = g.TargetOf(edge);
var targetGroups = groupGraph.GetGroupSet(target);
if (targetGroups.Contains(group))

Просмотреть файл

@ -604,19 +604,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble574_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble574_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
@ -628,12 +618,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}

Просмотреть файл

@ -493,9 +493,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
@ -506,24 +517,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble243_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScores_use_B[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_use_B[InstanceRange][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}

Просмотреть файл

@ -757,6 +757,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = JaggedSubarrayOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.IndexedWeights_B[InstanceRange][ClassRange], this.Weights_depth1_F[ClassRange], this.Weights_depth1_F_ClassRange__marginal[ClassRange], this.FeatureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[ClassRange][InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges]);
@ -782,7 +789,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble650_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble650_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_use_B[InstanceRange][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}

Просмотреть файл

@ -662,6 +662,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
@ -681,7 +688,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble319_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble319_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_use_B[InstanceRange][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}

Просмотреть файл

@ -12,24 +12,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public partial class GaussianDenseMulticlassBpmTrainingEvidence_EP : IGeneratedAlgorithm
{
#region Fields
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount</summary>
public bool Changed_ClassCount_FeatureCount_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3</summary>
@ -180,10 +172,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
}
@ -208,10 +198,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
}
@ -234,10 +222,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
@ -262,10 +248,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
}
@ -290,10 +274,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
@ -321,10 +303,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
@ -343,10 +323,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
@ -360,9 +338,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
this.ModelSelector_selector_cases_0_rep4_rep_uses_B = new Bernoulli[this.ClassCount][][];
this.Weights_depth0_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.ModelSelector_selector_cases_0_rep4_rep_B = new Bernoulli[this.ClassCount][];
this.ModelSelector_selector_cases_0_rep4_B = new Bernoulli[this.ClassCount];
this.Weights_depth0_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_F = new Gaussian[this.ClassCount][][];
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
@ -395,7 +373,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_F[ClassRange][_iv][0] = Gaussian.Uniform();
}
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
@ -418,6 +395,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_rep_B[ClassRange] = new Gaussian[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange] = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep4_rep_B[ClassRange] = new Bernoulli[this.FeatureCount];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv][0] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange] = new Bernoulli[3];
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange][1] = Bernoulli.Uniform();
@ -447,9 +427,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureValues and InstanceCount and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary>
/// <param name="numberOfIterations">The number of times to iterate each loop</param>
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18(int numberOfIterations)
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16(int numberOfIterations)
{
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone) {
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone) {
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
@ -477,15 +457,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
@ -503,6 +474,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_use_B[InstanceRange][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
@ -582,16 +556,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_marginal_F[ClassRange][FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_marginal_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = true;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureValues and InstanceCount and Labels and numberOfIterationsDecreased and WeightConstraints and WeightPriors</summary>
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17()
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15()
{
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone) {
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
@ -604,32 +586,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureValues and InstanceCount and numberOfIterationsDecreased and WeightConstraints and WeightPriors and must reset on changes to Labels</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = true;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised = true;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and InstanceCount</summary>
@ -676,24 +641,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_9_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and InstanceCount and numberOfIterationsDecreased and WeightConstraints and WeightPriors and must reset on changes to FeatureValues and Labels</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
}
}
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = true;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and numberOfIterationsDecreased and must reset on changes to FeatureValues and InstanceCount and Labels and WeightConstraints and WeightPriors</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3(bool initialise)
@ -703,7 +650,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
@ -715,6 +661,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F_marginal[ClassRange][FeatureRange] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
this.Weights_rep_B_toDef[ClassRange][FeatureRange] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.Weights_uses_F[ClassRange][FeatureRange][1]);
}
@ -848,30 +799,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
@ -955,6 +888,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.vdouble379_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
@ -1047,8 +982,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.ModelSelector_selector_cases_0_rep20_B[InstanceRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep24_rep_uses_B = new Bernoulli[this.InstanceCount][][];
this.ModelSelector_selector_cases_0_rep24_B = new Bernoulli[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep24_rep_B = new Bernoulli[this.InstanceCount][];
this.ModelSelector_selector_cases_0_rep24_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep24_B[InstanceRange] = Bernoulli.Uniform();
}
@ -1147,11 +1082,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
this.Constant();
this.Changed_InstanceCount();
@ -1169,10 +1102,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3(initialise);
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance5(initialise);
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7(initialise);
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15(initialise);
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16(initialise);
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17();
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18(numberOfIterations);
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15();
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16(numberOfIterations);
this.numberOfIterationsDone = numberOfIterations;
}

Просмотреть файл

@ -12,24 +12,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public partial class GaussianDenseMulticlassBpmTraining_EP : IGeneratedAlgorithm
{
#region Fields
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15</summary>
public bool Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15</summary>
public bool Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount</summary>
public bool Changed_ClassCount_FeatureCount_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3</summary>
@ -147,10 +139,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
}
@ -175,10 +165,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
}
@ -201,10 +189,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
@ -228,10 +214,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
}
@ -255,10 +239,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
@ -286,10 +268,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
@ -308,10 +288,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
}
@ -377,9 +355,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureValues and InstanceCount and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary>
/// <param name="numberOfIterations">The number of times to iterate each loop</param>
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18(int numberOfIterations)
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16(int numberOfIterations)
{
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone) {
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone) {
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
@ -407,15 +385,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
@ -433,6 +402,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_use_B[InstanceRange][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
@ -459,16 +431,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_marginal_F[ClassRange][FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_marginal_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = true;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureValues and InstanceCount and Labels and numberOfIterationsDecreased and WeightConstraints and WeightPriors</summary>
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17()
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15()
{
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone) {
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
@ -481,32 +461,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureValues and InstanceCount and numberOfIterationsDecreased and WeightConstraints and WeightPriors and must reset on changes to Labels</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.FeatureScores_F[InstanceRange][ClassRange][FeatureRange] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][FeatureRange], this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = true;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isInitialised = true;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and InstanceCount</summary>
@ -557,24 +520,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureValues_Labels_7_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and InstanceCount and numberOfIterationsDecreased and WeightConstraints and WeightPriors and must reset on changes to FeatureValues and Labels</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.Weights_rep_B[ClassRange][FeatureRange][InstanceRange], this.Weights_rep_F_marginal[ClassRange][FeatureRange], InstanceRange, this.Weights_rep_F[ClassRange][FeatureRange][InstanceRange]);
}
}
}
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = true;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and numberOfIterationsDecreased and must reset on changes to FeatureValues and InstanceCount and Labels and WeightConstraints and WeightPriors</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3(bool initialise)
@ -711,30 +656,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
@ -811,6 +738,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.vdouble48_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
@ -902,11 +831,9 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15_isDone = false;
}
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16_isDone = false;
}
this.Changed_InstanceCount();
this.Changed_ClassCount_InstanceCount();
@ -923,10 +850,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureValues_InstanceCount_Labels_3(initialise);
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureValues_Instance13(initialise);
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14(initialise);
this.Changed_ClassCount_FeatureCount_InstanceCount_numberOfIterationsDecreased_WeightConstraints_WeightPr15(initialise);
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_numberOfIterationsDecreased_WeightConstr16(initialise);
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh17();
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai18(numberOfIterations);
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterationsDecreased_Weigh15();
this.Changed_ClassCount_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstrai16(numberOfIterations);
this.numberOfIterationsDone = numberOfIterations;
}

Просмотреть файл

@ -12,30 +12,48 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public partial class GaussianSparseMulticlassBpmTrainingEvidence_EP : IGeneratedAlgorithm
{
#region Fields
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount</summary>
public bool Changed_ClassCount_FeatureCount_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_WeightConstraints has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_WeightConstraints</summary>
public bool Changed_ClassCount_FeatureCount_WeightConstraints_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised;
/// <summary>True if Changed_ClassCount_InstanceCount has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount</summary>
public bool Changed_ClassCount_InstanceCount_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels</summary>
public bool Changed_ClassCount_InstanceCount_Labels_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11</summary>
public bool Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11</summary>
public bool Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15</summary>
public bool Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15</summary>
public bool Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised;
/// <summary>True if Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13</summary>
public bool Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13</summary>
public bool Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised;
/// <summary>True if Changed_ClassCount has executed. Set this to false to force re-execution of Changed_ClassCount</summary>
public bool Changed_ClassCount_isDone;
/// <summary>True if Changed_FeatureCount has executed. Set this to false to force re-execution of Changed_FeatureCount</summary>
@ -153,13 +171,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isDone = false;
this.Changed_ClassCount_FeatureCount_isDone = false;
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
}
@ -175,12 +198,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised = false;
this.Changed_ClassCount_FeatureCount_isDone = false;
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
}
@ -197,10 +225,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.FeatureIndexes_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -216,10 +249,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -237,11 +275,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
}
@ -258,11 +301,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.InstanceFeatureCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -280,10 +328,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.numberOfIterationsDone = 0;
this.Changed_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -304,11 +357,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
set {
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised = false;
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -321,10 +379,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
set {
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -338,13 +401,13 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
this.ModelSelector_selector_cases_0_rep4_rep_uses_B = new Bernoulli[this.ClassCount][][];
this.Weights_depth0_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.ModelSelector_selector_cases_0_rep4_B = new Bernoulli[this.ClassCount];
this.ModelSelector_selector_cases_0_rep4_rep_B = new Bernoulli[this.ClassCount][];
this.Weights_uses_F = new Gaussian[this.ClassCount][][];
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_depth0_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.SharedWeightsFirst_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_use_B = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_uses_F = new Gaussian[this.ClassCount][][];
this.Weights_uses_B = new Gaussian[this.ClassCount][][];
this.Weights_depth1_F = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Weights_depth1_F_ClassRange__marginal = new DistributionStructArray<Gaussian,double>[this.ClassCount];
@ -373,36 +436,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
this.Weights_uses_F[ClassRange][_iv][0] = Gaussian.Uniform();
}
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = Gaussian.Uniform();
}
this.Weights_use_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
}
this.Weights_uses_B[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
@ -411,15 +456,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_uses_B[ClassRange][_iv][1] = Gaussian.Uniform();
}
this.Weights_depth1_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_depth1_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_B[ClassRange][_iv] = Gaussian.Uniform();
}
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange] = new Bernoulli[this.FeatureCount][];
this.ModelSelector_selector_cases_0_rep4_rep_B[ClassRange] = new Bernoulli[this.FeatureCount];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv][0] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange] = new Bernoulli[3];
this.ModelSelector_selector_cases_0_rep4_rep_uses_B[ClassRange][FeatureRange][1] = Bernoulli.Uniform();
@ -439,11 +484,49 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and numberOfIterationsDecreased and WeightConstraints and WeightPriors</summary>
private void Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16()
{
if (this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = JaggedSubarrayOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.IndexedWeights_B[InstanceRange][ClassRange], this.Weights_depth1_F[ClassRange], this.Weights_depth1_F_ClassRange__marginal[ClassRange], this.FeatureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[ClassRange][InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble418_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble418_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
}
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary>
/// <param name="numberOfIterations">The number of times to iterate each loop</param>
private void Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12(int numberOfIterations)
private void Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17(int numberOfIterations)
{
if (this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone) {
if (this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone) {
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
@ -477,6 +560,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
@ -487,25 +572,11 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble418_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble418_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_use_B[InstanceRange][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
@ -585,7 +656,21 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_marginal_F[ClassRange][FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_marginal_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = true;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureIndexes and InstanceCount and InstanceFeatureCounts and numberOfIterationsDecreased and WeightConstraints and WeightPriors and must reset on changes to FeatureValues and Labels</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.Marginal<DistributionStructArray<Gaussian,double>,Gaussian>(this.Weights_depth1_F[ClassRange], this.Weights_FeatureIndexes_B[ClassRange], this.FeatureIndexes, this.Weights_depth1_F_ClassRange__marginal[ClassRange]);
}
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = true;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and numberOfIterationsDecreased and must reset on changes to FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and WeightConstraints and WeightPriors</summary>
@ -596,15 +681,71 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_use_B[ClassRange][_iv] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
this.Weights_depth1_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.MarginalInit<DistributionStructArray<Gaussian,double>>(this.Weights_depth1_F[ClassRange]);
}
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone = true;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and numberOfIterationsDecreased and WeightConstraints and WeightPriors and must reset on changes to FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
}
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_F[ClassRange][_iv] = ArrayHelper.SetTo<Gaussian>(this.Weights_depth1_F[ClassRange][_iv], this.Weights_uses_F[ClassRange][_iv][1]);
}
}
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = true;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and numberOfIterationsDecreased and WeightPriors and must reset on changes to FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and WeightConstraints</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isDone = true;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and WeightConstraints</summary>
private void Changed_ClassCount_FeatureCount_WeightConstraints()
{
@ -633,13 +774,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.IndexedWeights_B[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
@ -649,10 +784,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.ModelSelector_selector_cases_0_rep27_rep_uses_B[InstanceRange] = new Bernoulli[this.ClassCount][];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep27_rep_uses_B[InstanceRange][ClassRange] = new Bernoulli[2];
this.ModelSelector_selector_cases_0_rep27_rep_uses_B[InstanceRange][ClassRange][1] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep27_rep_B[InstanceRange] = new Bernoulli[this.ClassCount];
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.ModelSelector_selector_cases_0_rep27_rep_uses_B[InstanceRange][ClassRange][1] = Bernoulli.Uniform();
this.ModelSelector_selector_cases_0_rep27_rep_B[InstanceRange][ClassRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep28_rep_B[InstanceRange] = new Bernoulli[this.ClassCount];
@ -670,14 +805,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_FeatureIndexes_B[ClassRange][InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.IndexedWeights_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
@ -689,21 +818,23 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>Computations that depend on the observed value of ClassCount and InstanceCount and InstanceFeatureCounts and numberOfIterationsDecreased and must reset on changes to FeatureCount and FeatureIndexes and FeatureValues and Labels and WeightConstraints and WeightPriors</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8(bool initialise)
private void Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10(bool initialise)
{
if (this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised)) {
if (this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_B[ClassRange][InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
this.IndexedWeights_B[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
}
}
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = true;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = true;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isDone = true;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and InstanceCount and Labels</summary>
@ -714,11 +845,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
@ -726,13 +852,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
@ -745,60 +864,24 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.vdouble418_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble418_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble418_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange] = new DistributionStructArray<Gaussian,double>[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
@ -862,27 +945,52 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>Computations that depend on the observed value of ClassCount and InstanceCount and Labels and numberOfIterationsDecreased and must reset on changes to FeatureCount and FeatureIndexes and FeatureValues and InstanceFeatureCounts and WeightConstraints and WeightPriors</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11(bool initialise)
private void Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15(bool initialise)
{
if (this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised)) {
if (this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.vdouble418_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
}
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isDone = true;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isInitialised = true;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isDone = true;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and InstanceCount and numberOfIterationsDecreased and must reset on changes to FeatureCount and FeatureIndexes and FeatureValues and InstanceFeatureCounts and Labels and WeightConstraints and WeightPriors</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13(bool initialise)
{
if (this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
}
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isDone = true;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of FeatureCount</summary>
@ -952,14 +1060,14 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.ModelSelector_selector_cases_0_rep23_B[InstanceRange] = Bernoulli.Uniform();
}
this.ModelSelector_selector_cases_0_rep27_rep_uses_B = new Bernoulli[this.InstanceCount][][];
this.ModelSelector_selector_cases_0_rep27_B = new Bernoulli[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep27_rep_B = new Bernoulli[this.InstanceCount][];
this.ModelSelector_selector_cases_0_rep27_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep27_B[InstanceRange] = Bernoulli.Uniform();
}
this.vbool44 = new bool[this.InstanceCount][][];
this.ModelSelector_selector_cases_0_rep28_B = new Bernoulli[this.InstanceCount];
this.ModelSelector_selector_cases_0_rep28_rep_B = new Bernoulli[this.InstanceCount][];
this.ModelSelector_selector_cases_0_rep28_B = new Bernoulli[this.InstanceCount];
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.ModelSelector_selector_cases_0_rep28_B[InstanceRange] = Bernoulli.Uniform();
}
@ -1051,11 +1159,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (numberOfIterations!=this.numberOfIterationsDone) {
if (numberOfIterations<this.numberOfIterationsDone) {
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
}
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
this.Constant();
this.Changed_InstanceCount();
@ -1064,13 +1177,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount();
this.Changed_ClassCount_InstanceCount();
this.Changed_ClassCount_InstanceCount_Labels();
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes11(initialise);
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur13(initialise);
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes15(initialise);
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts();
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8(initialise);
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount10(initialise);
this.Changed_ClassCount_FeatureCount();
this.Changed_ClassCount_FeatureCount_WeightConstraints();
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3(initialise);
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12(numberOfIterations);
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature5(initialise);
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat7(initialise);
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration11(initialise);
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16();
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17(numberOfIterations);
this.numberOfIterationsDone = numberOfIterations;
}

Просмотреть файл

@ -12,30 +12,48 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
public partial class GaussianSparseMulticlassBpmTraining_EP : IGeneratedAlgorithm
{
#region Fields
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15</summary>
public bool Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount</summary>
public bool Changed_ClassCount_FeatureCount_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13 has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isDone;
/// <summary>True if Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13</summary>
public bool Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised;
/// <summary>True if Changed_ClassCount_FeatureCount_WeightConstraints has executed. Set this to false to force re-execution of Changed_ClassCount_FeatureCount_WeightConstraints</summary>
public bool Changed_ClassCount_FeatureCount_WeightConstraints_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8</summary>
public bool Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised;
/// <summary>True if Changed_ClassCount_InstanceCount has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount</summary>
public bool Changed_ClassCount_InstanceCount_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels</summary>
public bool Changed_ClassCount_InstanceCount_Labels_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10</summary>
public bool Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10</summary>
public bool Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12</summary>
public bool Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12</summary>
public bool Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised;
/// <summary>True if Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10 has executed. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10</summary>
public bool Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isDone;
/// <summary>True if Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10 has performed initialisation. Set this to false to force re-execution of Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10</summary>
public bool Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised;
/// <summary>True if Changed_ClassCount has executed. Set this to false to force re-execution of Changed_ClassCount</summary>
public bool Changed_ClassCount_isDone;
/// <summary>True if Changed_FeatureCount has executed. Set this to false to force re-execution of Changed_FeatureCount</summary>
@ -121,13 +139,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = false;
this.Changed_ClassCount_FeatureCount_isDone = false;
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
}
@ -143,12 +166,17 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.FeatureCount_field = value;
this.numberOfIterationsDone = 0;
this.Changed_FeatureCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_FeatureCount_isDone = false;
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
}
@ -165,10 +193,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.FeatureIndexes_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -184,10 +217,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.FeatureValues_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -204,11 +242,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
}
@ -225,11 +268,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
this.InstanceFeatureCounts_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -246,10 +294,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Labels_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -270,11 +323,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
set {
this.WeightConstraints_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_FeatureCount_WeightConstraints_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -287,10 +345,15 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
set {
this.WeightPriors_field = value;
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
}
@ -325,13 +388,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.SharedWeightsFirst_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = Gaussian.Uniform();
}
this.Weights_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_marginal_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_marginal_F[ClassRange][_iv] = Gaussian.Uniform();
@ -340,7 +397,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_uses_F[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_uses_F[ClassRange][_iv] = new Gaussian[2];
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
}
this.Weights_uses_B[ClassRange] = new Gaussian[this.FeatureCount][];
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
@ -351,23 +407,10 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
}
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
}
this.Weights_depth1_F[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_depth1_B[ClassRange] = new DistributionStructArray<Gaussian,double>(this.FeatureCount);
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_B[ClassRange][_iv] = Gaussian.Uniform();
@ -376,11 +419,49 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and numberOfIterationsDecreased and WeightConstraints and WeightPriors</summary>
private void Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16()
{
if (this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = JaggedSubarrayOp<double>.ItemsAverageConditional<DistributionStructArray<Gaussian,double>,Gaussian,DistributionStructArray<Gaussian,double>>(this.IndexedWeights_B[InstanceRange][ClassRange], this.Weights_depth1_F[ClassRange], this.Weights_depth1_F_ClassRange__marginal[ClassRange], this.FeatureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[ClassRange][InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.FeatureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges]);
}
this.Scores_F[InstanceRange][ClassRange] = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange][ClassRange]);
this.NoisyScores_F[InstanceRange][ClassRange] = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Scores_F[InstanceRange][ClassRange], 1.0);
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = ReplicateOp_Divide.UsesAverageConditional<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore], ClassRange, this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
}
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary>
/// <param name="numberOfIterations">The number of times to iterate each loop</param>
private void Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12(int numberOfIterations)
private void Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17(int numberOfIterations)
{
if (this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone) {
if (this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone) {
return ;
}
for(int iteration = this.numberOfIterationsDone; iteration<numberOfIterations; iteration++) {
@ -414,6 +495,8 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.Marginal<Gaussian>(this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore], this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore]);
}
}
@ -424,26 +507,12 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.AAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(true), this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.SumAverageConditional(this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_F[InstanceRange][ClassRange]);
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = LowPriorityBackwardOp.ValueAverageConditional<Gaussian>(this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
}
}
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDef<Gaussian>(this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassMaxNoisyScore], this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = DoublePlusOp.BAverageConditional(this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_ClassRange_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
this.NoisyScores_use_B[InstanceRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.NoisyScores_use_B[InstanceRange][ClassRange], this.NoisyScores_ClassRange_ClassMaxNoisyScore_B[InstanceRange][ClassMaxNoisyScore][ClassRange]);
}
}
@ -472,7 +541,21 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Weights_marginal_F[ClassRange][FeatureRange] = DerivedVariableOp.MarginalAverageConditional<Gaussian>(this.Weights_use_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], this.Weights_marginal_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = true;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and FeatureIndexes and InstanceCount and InstanceFeatureCounts and numberOfIterationsDecreased and WeightConstraints and WeightPriors and must reset on changes to FeatureValues and Labels</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.Marginal<DistributionStructArray<Gaussian,double>,Gaussian>(this.Weights_depth1_F[ClassRange], this.Weights_FeatureIndexes_B[ClassRange], this.FeatureIndexes, this.Weights_depth1_F_ClassRange__marginal[ClassRange]);
}
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = true;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and numberOfIterationsDecreased and must reset on changes to FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and WeightConstraints and WeightPriors</summary>
@ -483,8 +566,20 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_F[ClassRange][_iv] = Gaussian.Uniform();
this.Weights_use_B[ClassRange][_iv] = Gaussian.Uniform();
this.Weights_uses_F[ClassRange][_iv][1] = Gaussian.Uniform();
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_F[FeatureRange][ClassRange] = Gaussian.Uniform();
this.TransposedWeights_B[FeatureRange][ClassRange] = Gaussian.Uniform();
}
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_F[ClassRange][_iv] = Gaussian.Uniform();
}
this.Weights_depth1_F_ClassRange__marginal[ClassRange] = JaggedSubarrayOp<double>.MarginalInit<DistributionStructArray<Gaussian,double>>(this.Weights_depth1_F[ClassRange]);
}
@ -492,6 +587,50 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and numberOfIterationsDecreased and WeightConstraints and WeightPriors and must reset on changes to FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_uses_F[ClassRange][FeatureRange][1] = ReplicateOp_NoDivide.UsesAverageConditional<Gaussian>(this.Weights_uses_B[ClassRange][FeatureRange], this.Weights_F[ClassRange][FeatureRange], 1, this.Weights_uses_F[ClassRange][FeatureRange][1]);
}
for(int _iv = 0; _iv<this.FeatureCount; _iv++) {
this.Weights_depth1_F[ClassRange][_iv] = ArrayHelper.SetTo<Gaussian>(this.Weights_depth1_F[ClassRange][_iv], this.Weights_uses_F[ClassRange][_iv][1]);
}
}
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = true;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and numberOfIterationsDecreased and WeightPriors and must reset on changes to FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and WeightConstraints</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13(bool initialise)
{
if (this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isDone&&((!initialise)||this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised)) {
return ;
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.SharedWeightsFirst_F[ClassRange][FeatureRange] = SequentialCopyOp.FirstAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.Weights_use_B[ClassRange][FeatureRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
this.TransposedWeights_F[FeatureRange][ClassRange] = ArrayHelper.SetTo<Gaussian>(this.TransposedWeights_F[FeatureRange][ClassRange], this.SharedWeightsFirst_F[ClassRange][FeatureRange]);
}
}
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.TransposedWeights_B[FeatureRange] = FastSumOp.ArrayAverageConditional<DistributionStructArray<Gaussian,double>>(0.0, this.TransposedWeights_F[FeatureRange], this.TransposedWeights_B[FeatureRange]);
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int FeatureRange = 0; FeatureRange<this.FeatureCount; FeatureRange++) {
this.Weights_F[ClassRange][FeatureRange] = SequentialCopyOp.SecondAverageConditional<Gaussian>(this.WeightPriors[ClassRange][FeatureRange], this.TransposedWeights_B[FeatureRange][ClassRange], this.Weights_F[ClassRange][FeatureRange]);
}
}
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isDone = true;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and FeatureCount and WeightConstraints</summary>
private void Changed_ClassCount_FeatureCount_WeightConstraints()
{
@ -518,13 +657,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.FeatureScores_F[InstanceRange] = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(this.ClassCount);
this.Scores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.NoisyScores_F[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
this.NoisyScores_use_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
this.Scores_B[InstanceRange] = new DistributionStructArray<Gaussian,double>(this.ClassCount);
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
@ -548,13 +681,7 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_F[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
this.FeatureScores_B[InstanceRange][ClassRange] = new DistributionStructArray<Gaussian,double>(this.InstanceFeatureCounts[InstanceRange]);
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.FeatureScores_B[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
@ -568,21 +695,23 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>Computations that depend on the observed value of ClassCount and InstanceCount and InstanceFeatureCounts and numberOfIterationsDecreased and must reset on changes to FeatureCount and FeatureIndexes and FeatureValues and Labels and WeightConstraints and WeightPriors</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11(bool initialise)
private void Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8(bool initialise)
{
if (this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised)) {
if (this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int InstanceFeatureRanges = 0; InstanceFeatureRanges<this.InstanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++) {
this.Weights_FeatureIndexes_F[ClassRange][InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
this.FeatureScores_F[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
this.IndexedWeights_B[InstanceRange][ClassRange][InstanceFeatureRanges] = Gaussian.Uniform();
this.Weights_FeatureIndexes_B[ClassRange][InstanceRange][InstanceFeatureRanges] = Gaussian.Uniform();
}
}
}
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isDone = true;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isInitialised = true;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = true;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and InstanceCount and Labels</summary>
@ -593,11 +722,6 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange] = new Gaussian[this.ClassCount];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
this.MaxNoisyScore_rep_B_toDef[InstanceRange] = new Gaussian[this.ClassCount];
this.MaxNoisyScore_rep_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
@ -605,73 +729,30 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
this.NoisyScoreDeltas_F[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.NoisyScoreDeltas_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.vdouble87_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.MaxNoisyScore_0__B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore] = new Gaussian[this.ClassCount];
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
if (ClassMaxNoisyScore!=ClassRange) {
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.MaxNoisyScore_rep_B[InstanceRange] = new Gaussian[this.ClassCount][];
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
@ -729,27 +810,52 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
/// <summary>Computations that depend on the observed value of ClassCount and InstanceCount and Labels and numberOfIterationsDecreased and must reset on changes to FeatureCount and FeatureIndexes and FeatureValues and InstanceFeatureCounts and WeightConstraints and WeightPriors</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10(bool initialise)
private void Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12(bool initialise)
{
if (this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised)) {
if (this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F_marginal[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.MarginalInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
this.MaxNoisyScore_rep_B_toDef[InstanceRange][ClassMaxNoisyScore] = ReplicateOp_Divide.ToDefInit<Gaussian>(this.NoisyScores_F[InstanceRange][ClassMaxNoisyScore]);
}
}
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
for(int ClassMaxNoisyScore = 0; ClassMaxNoisyScore<this.ClassCount; ClassMaxNoisyScore++) {
if (this.Labels[InstanceRange]==ClassMaxNoisyScore) {
this.MaxNoisyScore_rep_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
if (ClassMaxNoisyScore!=ClassRange) {
this.NoisyScoreDeltas_F[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.NoisyScoreDeltas_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.vdouble87_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
this.MaxNoisyScore_0__B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
this.MaxNoisyScore_rep_B[InstanceRange][ClassMaxNoisyScore][ClassRange] = Gaussian.Uniform();
}
}
}
}
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone = true;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isInitialised = true;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isDone = true;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of ClassCount and InstanceCount and numberOfIterationsDecreased and must reset on changes to FeatureCount and FeatureIndexes and FeatureValues and InstanceFeatureCounts and Labels and WeightConstraints and WeightPriors</summary>
/// <param name="initialise">If true, reset messages that initialise loops</param>
private void Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10(bool initialise)
{
if (this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isDone&&((!initialise)||this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised)) {
return ;
}
for(int InstanceRange = 0; InstanceRange<this.InstanceCount; InstanceRange++) {
for(int ClassRange = 0; ClassRange<this.ClassCount; ClassRange++) {
this.Scores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
this.NoisyScores_F[InstanceRange][ClassRange] = Gaussian.Uniform();
}
}
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isDone = true;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isInitialised = true;
}
/// <summary>Computations that depend on the observed value of FeatureCount</summary>
@ -811,11 +917,16 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
if (numberOfIterations!=this.numberOfIterationsDone) {
if (numberOfIterations<this.numberOfIterationsDone) {
this.numberOfIterationsDone = 0;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11_isDone = false;
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10_isDone = false;
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12_isDone = false;
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13_isDone = false;
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16_isDone = false;
}
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12_isDone = false;
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17_isDone = false;
}
this.Changed_InstanceCount();
this.Constant();
@ -823,13 +934,18 @@ namespace Microsoft.ML.Probabilistic.Learners.BayesPointMachineClassifierInterna
this.Changed_ClassCount();
this.Changed_ClassCount_InstanceCount();
this.Changed_ClassCount_InstanceCount_Labels();
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes10(initialise);
this.Changed_ClassCount_InstanceCount_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes_Featur10(initialise);
this.Changed_ClassCount_InstanceCount_Labels_numberOfIterationsDecreased_Init_FeatureCount_FeatureIndexes12(initialise);
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts();
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount11(initialise);
this.Changed_ClassCount_InstanceCount_InstanceFeatureCounts_numberOfIterationsDecreased_Init_FeatureCount8(initialise);
this.Changed_ClassCount_FeatureCount();
this.Changed_ClassCount_FeatureCount_WeightConstraints();
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_Init_FeatureIndexes_FeatureValues_Instan3(initialise);
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab12(numberOfIterations);
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightPriors_Init_FeatureIndexes_Feature13(initialise);
this.Changed_ClassCount_FeatureCount_numberOfIterationsDecreased_WeightConstraints_WeightPriors_Init_Feat14(initialise);
this.Changed_ClassCount_FeatureCount_FeatureIndexes_InstanceCount_InstanceFeatureCounts_numberOfIteration15(initialise);
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab16();
this.Changed_ClassCount_FeatureCount_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Lab17(numberOfIterations);
this.numberOfIterationsDone = numberOfIterations;
}

Просмотреть файл

@ -274,10 +274,8 @@ namespace Microsoft.ML.Probabilistic.Distributions
else if (IsUniform()) result.SetAllElementsTo(0.0);
else
{
// TM: Don't need to check for PosDef because Inverse already does.
//if(!precision.IsPositiveDefinite()) throw new ArgumentException("Improper distribution", "this");
result.SetTo(meanTimesPrecision);
result.PredivideBy(this.Precision);
result.PredivideBy(this.Precision); // will throw if Precision is not posdef
for (int i = 0; i < Dimension; i++)
{
if (Double.IsPositiveInfinity(precision[i, i])) result[i] = meanTimesPrecision[i];
@ -887,19 +885,42 @@ namespace Microsoft.ML.Probabilistic.Distributions
{
if (numerator.precision[i, i] < denominator.precision[i, i])
{
// Precision difference is not posdef.
isImproper = true;
break;
}
}
if (isImproper)
{
//throw new NotImplementedException();
// Act as though numerator.precision was changed to equal denominator.precision,
// and numerator.MeanTimesPrecision was changed to tau.
tau = denominator.precision * numerator.GetMean();
Precision.SetAllElementsTo(0);
// cannot access numerator.precision after this
// Should not access numerator.precision after this point, since numerator could be the same object as this.
}
else if (IsDifferenceDiagonallyDominant())
{
// Precision difference must be posdef
precision.SetToDifference(numerator.precision, denominator.precision);
}
else
{
// We can't easily tell if the precision difference is posdef or not.
// Must use an expensive test.
var mean = numerator.GetMean();
precision.SetToDifference(numerator.precision, denominator.precision);
isImproper = !precision.IsPositiveDefinite();
if (isImproper)
{
tau = denominator.precision * mean;
Precision.SetAllElementsTo(0);
}
}
}
if (tau == null) precision.SetToDifference(numerator.precision, denominator.precision);
else
{
precision.SetToDifference(numerator.precision, denominator.precision);
}
for (int i = 0; i < Dimension; i++)
{
if (Double.IsPositiveInfinity(precision[i, i]))
@ -943,6 +964,22 @@ namespace Microsoft.ML.Probabilistic.Distributions
}
}
}
bool IsDifferenceDiagonallyDominant()
{
for (int i = 0; i < Dimension; i++)
{
double sum = 0;
for (int j = 0; j < Dimension; j++)
{
double diff = numerator.precision[i, j] - denominator.precision[i, j];
if (i == j) sum += diff;
else sum -= Math.Abs(diff);
}
if (sum <= 0) return false;
}
return true;
}
}
/// <summary>

Просмотреть файл

@ -181,8 +181,14 @@ namespace Microsoft.ML.Probabilistic.Factors
double logWeightSum = logProbSum;
if (!double.IsNegativeInfinity(logWeightSum))
{
logWeightSum -= enterPartial[0].GetLogAverageOf(value);
result.SetTo(enterPartial[0]);
// Subtract to avoid double-counting since selector already contains this quantity
// See IntCasesOp.IAverageConditional
double logAverage = enterPartial[0].GetLogAverageOf(value);
if (!double.IsNegativeInfinity(logAverage))
{
logWeightSum -= logAverage;
result.SetTo(enterPartial[0]);
}
}
if (indices.Length > 1)
@ -208,9 +214,13 @@ namespace Microsoft.ML.Probabilistic.Factors
double logWeightShifted = logProb - shift;
if (!double.IsNegativeInfinity(logWeightShifted))
{
logWeightShifted -= enterPartial[i].GetLogAverageOf(value);
result.SetToSum(Math.Exp(logWeightSum - shift), result, Math.Exp(logWeightShifted), enterPartial[i]);
logWeightSum = MMath.LogSumExp(logWeightSum, logWeightShifted + shift);
double logAverage = enterPartial[i].GetLogAverageOf(value);
if (!double.IsNegativeInfinity(logAverage))
{
logWeightShifted -= logAverage;
result.SetToSum(Math.Exp(logWeightSum - shift), result, Math.Exp(logWeightShifted), enterPartial[i]);
logWeightSum = MMath.LogSumExp(logWeightSum, logWeightShifted + shift);
}
}
}
}

Просмотреть файл

@ -97,7 +97,7 @@ namespace Microsoft.ML.Probabilistic.Factors
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateExitingOp"]/message_doc[@name="UsesAverageLogarithmInit{T}(T, int)"]/*'/>
/// <typeparam name="T">The type of the messages.</typeparam>
[Skip]
public static T UsesAverageLogarithmInit<T>(T Def, int resultIndex)
public static T UsesAverageLogarithmInit<T>(T Def, [IgnoreDependency] int resultIndex)
where T : ICloneable
{
return (T)Def.Clone();

Просмотреть файл

@ -29,6 +29,13 @@ namespace Microsoft.ML.Probabilistic.Factors
return value;
}
[ParameterNames("first", "value", "second")]
public static T ParallelCopy<T>(T value, out T second)
{
second = value;
return value;
}
[ParameterNames("first", "value", "second")]
public static T SequentialCut<T>(T value, out T second)
{
@ -103,6 +110,44 @@ namespace Microsoft.ML.Probabilistic.Factors
}
}
[FactorMethod(typeof(LowPriority), "ParallelCopy<>")]
[Quality(QualityBand.Preview)]
public static class ParallelCopyOp
{
[SkipIfAllUniform]
public static double LogEvidenceRatio<T>(T value, T first, T second)
where T : CanGetLogAverageOf<T>, SettableToProduct<T>, ICloneable
{
T valueTimesFirst = (T)value.Clone();
valueTimesFirst.SetToProduct(value, first);
return value.GetLogAverageOf(second) - valueTimesFirst.GetLogAverageOf(second);
}
[SkipIfAllUniform]
public static T FirstAverageConditional<T>(T value, [NoInit] T second, T result)
where T : SettableToProduct<T>
{
result.SetToProduct(value, second);
return result;
}
[SkipIfAllUniform]
public static T SecondAverageConditional<T>(T value, [NoInit] T first, T result)
where T : SettableToProduct<T>
{
result.SetToProduct(value, first);
return result;
}
[SkipIfAllUniform]
public static T ValueAverageConditional<T>(T first, T second, T result)
where T : SettableToProduct<T>
{
result.SetToProduct(first, second);
return result;
}
}
[FactorMethod(typeof(LowPriority), "Forward<>")]
[Quality(QualityBand.Preview)]
public static class LowPriorityForwardOp

Просмотреть файл

@ -103,6 +103,8 @@ namespace Microsoft.ML.Probabilistic.Factors
return LogAverageFactor(product, A, B, BMean, BVariance);
}
// Modifies mean and variance
// If BVariance is infinity, results may contain NaN
private static void GetProductMoments(Matrix A, Vector BMean, PositiveDefiniteMatrix BVariance, Vector mean, PositiveDefiniteMatrix variance)
{
// P.mean = A*B.mean
@ -308,7 +310,7 @@ namespace Microsoft.ML.Probabilistic.Factors
if (!A.IsPointMass) throw new ArgumentException("A is not a point mass");
// logZ = log N(mProduct; A*BMean, vProduct + A*BVariance*A')
// = -0.5 (mProduct - A*BMean)' inv(vProduct + A*BVariance*A') (mProduct - A*BMean) - 0.5 logdet(vProduct + A*BVariance*A')
// = -0.5 (mProduct - A*BMean)' pPrec inv(pProduct + pProduct*A*BVariance*A'*pProduct) pProduct (mProduct - A*BMean)
// = -0.5 (mProduct - A*BMean)' pProduct inv(pProduct + pProduct*A*BVariance*A'*pProduct) pProduct (mProduct - A*BMean)
// - 0.5 logdet(pProduct + pProduct*A*BVariance*A'*pProduct) + logdet(pProduct)
// dlogZ = 0.5 (dA*BMean)' pProduct inv(pProduct + pProduct*A*BVariance*A'*pProduct) pProduct (mProduct - A*BMean)
// +0.5 (mProduct - A*BMean)' pProduct inv(pProduct + pProduct*A*BVariance*A'*pProduct) pProduct (dA*BMean)
@ -352,6 +354,21 @@ namespace Microsoft.ML.Probabilistic.Factors
// for now, we don't compute the second derivative.
double ddlogp = -1;
result[i, j] = Gaussian.FromDerivatives(A[i, j].Point, dlogp, ddlogp, false);
bool check = false;
if (check)
{
double logZ(Matrix m)
{
var vgm = ProductAverageConditional(m, BMean, BVariance, new VectorGaussianMoments(m.Rows));
return VectorGaussian.GetLogProb(product.GetMean(), vgm.Mean, product.GetVariance() + vgm.Variance);
}
var Amatrix2 = (Matrix)Amatrix.Clone();
double delta = 1e-4;
Amatrix2[i, j] += delta;
double dlogp2 = (logZ(Amatrix2) - logZ(Amatrix)) / delta;
if (MMath.AbsDiff(dlogp, dlogp2, 1e-10) > 1e-5) throw new Exception();
}
}
}
return result;

Просмотреть файл

@ -1023,6 +1023,7 @@ namespace Microsoft.ML.Probabilistic.Factors
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="GaussianProductOp_LaplaceProp"]/message_doc[@name="AAverageConditional(Gaussian, Gaussian, Gaussian, Gaussian)"]/*'/>
public static Gaussian AAverageConditional(Gaussian Product, Gaussian A, Gaussian B, Gaussian to_A)
{
// The factor is N(mx; ahat * mb, vx + ahat * ahat * vb)
Gaussian Apost = A * to_A;
double mx, vx;
Product.GetMeanAndVariance(out mx, out vx);

Просмотреть файл

@ -9,7 +9,6 @@ namespace Microsoft.ML.Probabilistic.Factors
{
using System;
using System.Collections.Generic;
using Microsoft.ML.Probabilistic;
using Microsoft.ML.Probabilistic.Collections;
using Microsoft.ML.Probabilistic.Distributions;
using Microsoft.ML.Probabilistic.Math;
@ -96,6 +95,86 @@ namespace Microsoft.ML.Probabilistic.Factors
}
}
[FactorMethod(typeof(Clone), "Replicate<>", Default = false)]
[Buffers("marginal", "toDef")]
[Quality(QualityBand.Mature)]
public static class ReplicateOp_Divide_NoInit
{
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateOp_Divide"]/message_doc[@name="DefAverageConditional{T}(T, T)"]/*'/>
/// <typeparam name="T">The type of the messages.</typeparam>
public static T DefAverageConditional<T>([IsReturned] T toDef, T result)
where T : SettableTo<T>
{
result.SetTo(toDef);
return result;
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateOp_Divide"]/message_doc[@name="UsesAverageConditional{T}(T, T, int, T)"]/*'/>
/// <typeparam name="T">The type of the messages.</typeparam>
// Uses is marked Cancels because the forward message does not really depend on the backward message
public static T UsesAverageConditional<T>([Indexed, Cancels] T Uses, [SkipIfUniform] T marginal, [IgnoreDependency] int resultIndex, T result)
where T : SettableToRatio<T>
{
result.SetToRatio(marginal, Uses);
return result;
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateOp_Divide"]/message_doc[@name="MarginalInit{T}(T)"]/*'/>
/// <typeparam name="T">The type of the messages.</typeparam>
[Skip] // must have Skip since marginal is Fresh
public static T MarginalInit<T>([SkipIfUniform] T Def)
where T : ICloneable
{
return (T)Def.Clone();
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateOp_Divide"]/message_doc[@name="Marginal{T}(T, T, T)"]/*'/>
/// <typeparam name="T">The type of the messages.</typeparam>
[SkipIfAllUniform]
[MultiplyAll]
[Fresh]
public static T Marginal<T>([NoInit] T toDef, T Def, T result)
where T : SettableToProduct<T>
{
result.SetToProduct(Def, toDef);
return result;
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateOp_Divide"]/message_doc[@name="MarginalIncrement{T}(T, T, T)"]/*'/>
/// <typeparam name="T">The type of the messages.</typeparam>
// SkipIfUniform on 'use' causes this line to be pruned when the backward message isn't changing
[SkipIfAllUniform]
[MultiplyAll]
[Fresh]
public static T MarginalIncrement<T>(T result, [InducedSource] T def, [SkipIfUniform, InducedTarget] T use)
where T : SettableToProduct<T>
{
result.SetToProduct(use, def);
return result;
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateOp_Divide"]/message_doc[@name="ToDefInit{T}(T)"]/*'/>
/// <typeparam name="T">The type of the messages.</typeparam>
[Skip] // this is needed to instruct the scheduler to treat the buffer as uninitialized
public static T ToDefInit<T>(T Def)
where T : ICloneable, SettableToUniform
{
// must construct from Def instead of Uses because Uses array may be empty
return ArrayHelper.MakeUniform(Def);
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateOp_Divide"]/message_doc[@name="ToDef{T}(IList{T}, T)"]/*'/>
/// <typeparam name="T">The type of the messages.</typeparam>
[SkipIfAllUniform]
[MultiplyAll]
[Fresh]
public static T ToDef<T>(IReadOnlyList<T> Uses, T result)
where T : SettableToProduct<T>, SettableTo<T>, SettableToUniform
{
return Distribution.SetToProductOfAll(result, Uses);
}
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="Replicate2BufferOp"]/doc/*'/>
[FactorMethod(typeof(Clone), "Replicate<>", Default = false)]
[Buffers("marginal")]
@ -475,7 +554,7 @@ namespace Microsoft.ML.Probabilistic.Factors
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateOp"]/message_doc[@name="UsesAverageLogarithm{T, TDef}(TDef, int, T)"]/*'/>
/// <typeparam name="T">The type of the outgoing message.</typeparam>
/// <typeparam name="TDef">The type of the incoming message from <c>Def</c>.</typeparam>
public static T UsesAverageLogarithm<T, TDef>([IsReturned] TDef Def, int resultIndex, T result)
public static T UsesAverageLogarithm<T, TDef>([IsReturned] TDef Def, [IgnoreDependency] int resultIndex, T result)
where T : SettableTo<TDef>
{
result.SetTo(Def);
@ -578,7 +657,7 @@ namespace Microsoft.ML.Probabilistic.Factors
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateMaxOp"]/message_doc[@name="UsesMaxConditionalInit{T}(T, int)"]/*'/>
/// <typeparam name="T">The type of the distribution o0ver the replicated variable.</typeparam>
[Skip]
public static T UsesMaxConditionalInit<T>([IgnoreDependency] T Def, int resultIndex)
public static T UsesMaxConditionalInit<T>([IgnoreDependency] T Def, [IgnoreDependency] int resultIndex)
where T : ICloneable
{
return (T)Def.Clone();

Просмотреть файл

@ -66,7 +66,7 @@ namespace Microsoft.ML.Probabilistic.Factors
#else
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateGibbsOp{T}"]/message_doc[@name="UsesGibbs{TDist}(GibbsMarginal{TDist, T}, TDist, int, T)"]/*'/>
/// <typeparam name="TDist">The type of the distribution over the replicated variable.</typeparam>
public static T UsesGibbs<TDist>([SkipIfUniform] GibbsMarginal<TDist, T> to_marginal, TDist def, int resultIndex, T result)
public static T UsesGibbs<TDist>([SkipIfUniform] GibbsMarginal<TDist, T> to_marginal, [IgnoreDependency] TDist def, [IgnoreDependency] int resultIndex, T result)
where TDist : IDistribution<T>, Sampleable<T>
{
// This method must depend on Def, even though Def isn't used, in order to get the right triggers
@ -74,7 +74,7 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateGibbsOp{T}"]/message_doc[@name="UsesGibbs(T, int, T)"]/*'/>
public static T UsesGibbs([IsReturned] T def, int resultIndex, T result)
public static T UsesGibbs([IsReturned] T def, [IgnoreDependency] int resultIndex, T result)
{
return def;
}
@ -84,7 +84,7 @@ namespace Microsoft.ML.Probabilistic.Factors
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateGibbsOp{T}"]/message_doc[@name="UsesGibbs{TDist}(TDist, int, TDist)"]/*'/>
/// <typeparam name="TDist">The type of the distribution over the replicated variable.</typeparam>
// until .NET 4
public static TDist UsesGibbs<TDist>([IsReturned] TDist def, int resultIndex, TDist result)
public static TDist UsesGibbs<TDist>([IsReturned] TDist def, [IgnoreDependency] int resultIndex, TDist result)
where TDist : IDistribution<T>
{
return def;
@ -321,14 +321,14 @@ namespace Microsoft.ML.Probabilistic.Factors
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateGibbsOp2{T}"]/message_doc[@name="UsesGibbs(T, int, T)"]/*'/>
public static T UsesGibbs([IsReturned] T def, int resultIndex, T result)
public static T UsesGibbs([IsReturned] T def, [IgnoreDependency] int resultIndex, T result)
{
return def;
}
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateGibbsOp2{T}"]/message_doc[@name="UsesGibbs{TDist}(TDist, T, int, T)"]/*'/>
/// <typeparam name="TDist">The type of the distribution over the replicated variable.</typeparam>
public static T UsesGibbs<TDist>(TDist def, T sample, int resultIndex, T result)
public static T UsesGibbs<TDist>(TDist def, T sample, [IgnoreDependency] int resultIndex, T result)
where TDist : IDistribution<T>
{
// This method must depend on Def, even though Def isn't used, in order to get the right triggers
@ -340,7 +340,7 @@ namespace Microsoft.ML.Probabilistic.Factors
public static TDist UsesGibbs<TDist>(
[IgnoreDependency] ICollection<TDist> Uses,
[IsReturned] TDist Def,
int resultIndex, TDist result)
[IgnoreDependency] int resultIndex, TDist result)
where TDist : IDistribution<T>, Sampleable<T>, SettableTo<TDist>, SettableToProduct<TDist>, SettableToRatio<TDist>
{
if (resultIndex < 0 || resultIndex >= Uses.Count)
@ -354,7 +354,7 @@ namespace Microsoft.ML.Probabilistic.Factors
/// <include file='FactorDocs.xml' path='factor_docs/message_op_class[@name="ReplicateGibbsOp2{T}"]/message_doc[@name="UsesGibbsInit{TDist}(TDist, int)"]/*'/>
/// <typeparam name="TDist">The type of the distribution over the replicated variable.</typeparam>
[Skip]
public static TDist UsesGibbsInit<TDist>([IgnoreDependency] TDist Def, int resultIndex)
public static TDist UsesGibbsInit<TDist>([IgnoreDependency] TDist Def, [IgnoreDependency] int resultIndex)
where TDist : ICloneable
{
return (TDist)Def.Clone();

Просмотреть файл

@ -27,7 +27,7 @@ namespace Microsoft.ML.Probabilistic.Factors
/// <typeparam name="T">The type of the outgoing message.</typeparam>
/// <typeparam name="TDef">The type of the incoming message from <c>Def</c>.</typeparam>
public static T UsesAverageConditional<T, TDef>([IsReturned] TDef Def, int resultIndex, T result)
public static T UsesAverageConditional<T, TDef>([IsReturned] TDef Def, [IgnoreDependency] int resultIndex, T result)
where T : SettableTo<TDef>
{
// Def will always be a point mass, so no division is needed.

Просмотреть файл

@ -37,7 +37,7 @@ namespace Microsoft.ML.Probabilistic.Factors
return 0.0;
}
public static double LogEvidenceRatio<ItemType>(IReadOnlyList<ItemType> array, IReadOnlyList<T> head, int count, IReadOnlyList<T> tail)
public static double LogEvidenceRatio<ItemType>([SkipIfAllUniform] IReadOnlyList<ItemType> array, IReadOnlyList<T> head, int count, IReadOnlyList<T> tail)
where ItemType : CanGetLogProb<T>
{
double sum = 0;
@ -74,6 +74,7 @@ namespace Microsoft.ML.Probabilistic.Factors
return sum;
}
[SkipIfAllUniform]
public static ArrayType ArrayAverageConditional<ArrayType, ItemType>(IReadOnlyList<ItemType> head, int count, IReadOnlyList<ItemType> tail, ArrayType result)
where ArrayType : IList<ItemType>
where ItemType : SettableTo<ItemType>
@ -93,7 +94,7 @@ namespace Microsoft.ML.Probabilistic.Factors
return result;
}
public static ArrayType ArrayAverageConditional<ArrayType, ItemType>(IReadOnlyList<T> head, int count, IReadOnlyList<ItemType> tail, ArrayType result)
public static ArrayType ArrayAverageConditional<ArrayType, ItemType>(IReadOnlyList<T> head, int count, [SkipIfAllUniform] IReadOnlyList<ItemType> tail, ArrayType result)
where ArrayType : IList<ItemType>
where ItemType : SettableTo<ItemType>, HasPoint<T>
{
@ -112,7 +113,7 @@ namespace Microsoft.ML.Probabilistic.Factors
return result;
}
public static ArrayType ArrayAverageConditional<ArrayType, ItemType>(IReadOnlyList<ItemType> head, int count, IReadOnlyList<T> tail, ArrayType result)
public static ArrayType ArrayAverageConditional<ArrayType, ItemType>([SkipIfAllUniform] IReadOnlyList<ItemType> head, int count, IReadOnlyList<T> tail, ArrayType result)
where ArrayType : IList<ItemType>
where ItemType : SettableTo<ItemType>, HasPoint<T>
{
@ -150,7 +151,7 @@ namespace Microsoft.ML.Probabilistic.Factors
return result;
}
public static ArrayType HeadAverageConditional<ArrayType, ItemType>(IReadOnlyList<ItemType> array, int count, ArrayType result)
public static ArrayType HeadAverageConditional<ArrayType, ItemType>([SkipIfAllUniform] IReadOnlyList<ItemType> array, int count, ArrayType result)
where ArrayType : IList<ItemType>
where ItemType : SettableTo<ItemType>
{
@ -165,7 +166,7 @@ namespace Microsoft.ML.Probabilistic.Factors
return result;
}
public static ArrayType TailAverageConditional<ArrayType, ItemType>(IReadOnlyList<ItemType> array, int count, ArrayType result)
public static ArrayType TailAverageConditional<ArrayType, ItemType>([SkipIfAllUniform] IReadOnlyList<ItemType> array, int count, ArrayType result)
where ArrayType : IList<ItemType>
where ItemType : SettableTo<ItemType>
{

Просмотреть файл

@ -65,8 +65,7 @@ namespace Microsoft.ML.Probabilistic.Factors
}
return result;
}
double sumMean, sumVariance;
sumExcept.GetMeanAndVarianceImproper(out sumMean, out sumVariance);
sumExcept.GetMeanAndVarianceImproper(out double sumMean, out double sumVariance);
double[] means = new double[array.Count];
double[] variances = new double[array.Count];
for (int i = 0; i < array.Count; i++)
@ -74,8 +73,7 @@ namespace Microsoft.ML.Probabilistic.Factors
// could generalize this to be predicate(i)
if (i == index)
continue;
double mean1, variance1;
array[i].GetMeanAndVarianceImproper(out mean1, out variance1);
array[i].GetMeanAndVarianceImproper(out double mean1, out double variance1);
means[i] = mean1;
variances[i] = variance1;
}

Просмотреть файл

@ -0,0 +1,4 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"methodDisplay": "method"
}

Просмотреть файл

@ -61,8 +61,8 @@ namespace TestApp
//InferenceEngine.DefaultEngine.Compiler.OptimiseInferenceCode = false;
//InferenceEngine.DefaultEngine.Compiler.FreeMemory = false;
//InferenceEngine.DefaultEngine.Compiler.ReturnCopies = false;
//InferenceEngine.DefaultEngine.Compiler.UnrollLoops = true;
//InferenceEngine.DefaultEngine.Compiler.UseParallelForLoops = true;
//InferenceEngine.DefaultEngine.Compiler.UnrollLoops = false;
//InferenceEngine.DefaultEngine.Compiler.UseParallelForLoops = false;
//InferenceEngine.DefaultEngine.ShowTimings = true;
//InferenceEngine.DefaultEngine.ShowProgress = false;
//InferenceEngine.DefaultEngine.ShowFactorGraph = true;
@ -83,13 +83,12 @@ namespace TestApp
Stopwatch watch = new Stopwatch();
watch.Start();
bool runAllTests = false;
if (runAllTests)
{
// Run all tests (need to run in 64-bit else OutOfMemory due to loading many DLLs)
// This is useful when looking for failures due to certain compiler options.
Console.WriteLine(StringUtil.VerboseToString(TestUtils.GetTestResultPaths()));
//Console.WriteLine(StringUtil.VerboseToString(TestUtils.GetTestResultPaths()));
//string path = @"C:\Users\minka\Depots\mlp\infernet\Infer2\TestResults\minka_MSRC-MINKA3 2013-04-11 14_36_55.trx";
InferenceEngine.DefaultEngine.Compiler.RecommendedQuality = QualityBand.Preview;
InferenceEngine.DefaultEngine.Compiler.GenerateInMemory = true;

Просмотреть файл

@ -726,6 +726,11 @@ namespace Microsoft.ML.Probabilistic.Tests
g = new VectorGaussian(Vector.FromArray(2, 3), new PositiveDefiniteMatrix(new double[,] { { 1, 0 }, { 0, 0 } }));
Assert.True(Double.IsPositiveInfinity(g.Precision[1, 1]));
Assert.Equal(3.0, g.Point[1]);
g = new VectorGaussian(Vector.FromArray(-15.01, 45.69), new PositiveDefiniteMatrix(new double[,] { { 9.067, -13.74 }, { -13.74, 26.56 } }));
g2 = new VectorGaussian(Vector.FromArray(-14.8, 45.78), new PositiveDefiniteMatrix(new double[,] { { 9.059, -13.69 }, { -13.69, 26.51 } }));
g.SetToRatio(g, g2, forceProper: true);
Assert.True(g.Precision.EqualsAll(0.0));
}
[Fact]

Просмотреть файл

@ -260,11 +260,10 @@ namespace Microsoft.ML.Probabilistic.Tests
}
block.CloseBlock();
InferenceEngine engine = new InferenceEngine();
object statesActual = engine.Infer(states);
Console.WriteLine("states = ");
Console.WriteLine(statesActual);
var statesActual = engine.Infer<IList<Gaussian>>(states);
double evActual = engine.Infer<Bernoulli>(evidence).LogOdds;
Console.WriteLine("evidence = {0}", System.Math.Exp(evActual));
Gaussian state2Expected = new Gaussian(1, 1);
Assert.True(state2Expected.MaxDiff(statesActual[2]) < 1e-10);
}
[Fact]
@ -289,20 +288,48 @@ namespace Microsoft.ML.Probabilistic.Tests
}
block.CloseBlock();
InferenceEngine engine = new InferenceEngine();
object statesActual = engine.Infer(states);
Console.WriteLine("states = ");
Console.WriteLine(statesActual);
var statesActual = engine.Infer<IList<Gaussian>>(states);
double evActual = engine.Infer<Bernoulli>(evidence).LogOdds;
Console.WriteLine("evidence = {0}", System.Math.Exp(evActual));
Assert.True(MMath.AbsDiff(0, evActual) < 1e-10);
Gaussian state2Expected = new Gaussian(0, 1002);
Console.WriteLine("expected states[2] = {0}", state2Expected);
Assert.True(state2Expected.MaxDiff(((DistributionArray<Gaussian, double>)statesActual)[2]) < 1e-10);
Assert.True(state2Expected.MaxDiff(statesActual[2]) < 1e-10);
}
[Fact]
public void CaseLoopIndexTest3()
{
Variable<bool> evidence = Variable.Bernoulli(0.5).Named("evidence");
IfBlock block = Variable.If(evidence);
Range rows = new Range(4).Named("i");
VariableArray<double> states = Variable.Array<double>(rows).Named("states");
using (ForEachBlock rowBlock = Variable.ForEach(rows))
{
using (Variable.Case(rowBlock.Index, 0))
{
states[rowBlock.Index] = Variable.GaussianFromMeanAndVariance(0, 1000);
}
using (Variable.Case(rowBlock.Index, 1))
{
states[rowBlock.Index] = Variable.GaussianFromMeanAndVariance(1, 1000);
}
using (Variable.If(rowBlock.Index > 1))
{
Variable<int> rowMinusOne = rowBlock.Index - 1;
states[rowBlock.Index] = Variable.GaussianFromMeanAndVariance(states[rowMinusOne], 1);
}
}
block.CloseBlock();
InferenceEngine engine = new InferenceEngine();
var statesActual = engine.Infer<IList<Gaussian>>(states);
double evActual = engine.Infer<Bernoulli>(evidence).LogOdds;
Assert.True(MMath.AbsDiff(0, evActual) < 1e-10);
Gaussian state3Expected = new Gaussian(1, 1002);
Assert.True(state3Expected.MaxDiff(statesActual[3]) < 1e-10);
}
// Fails with error: Cannot a define a variable more than once in the same condition context
//[Fact]
internal void CaseLoopIndexTest3()
internal void CaseLoopIndexBroken()
{
Range rows = new Range(3).Named("i");
VariableArray<double> states = Variable.Array<double>(rows).Named("states");
@ -5187,15 +5214,14 @@ namespace Microsoft.ML.Probabilistic.Tests
Variable<int> b = Variable.New<int>().Named("b");
Bernoulli cPrior = new Bernoulli(0.1);
Variable<bool> c = Variable.Bernoulli(0.1).Named("c");
Bernoulli cLike0 = new Bernoulli(0.2);
Bernoulli cLike1 = new Bernoulli(0.3);
VariableArray<Bernoulli> cLike = Variable.Observed(new Bernoulli[] { new Bernoulli(0.2), new Bernoulli(0.3) }).Named("cLike");
using (Variable.Case(b, 0))
{
Variable.ConstrainEqualRandom(c, cLike0);
Variable.ConstrainEqualRandom(c, cLike[0]);
}
using (Variable.Case(b, 1))
{
Variable.ConstrainEqualRandom(c, cLike1);
Variable.ConstrainEqualRandom(c, cLike[1]);
}
InferenceEngine engine = new InferenceEngine();
Bernoulli cExpected;
@ -5206,11 +5232,11 @@ namespace Microsoft.ML.Probabilistic.Tests
b.ObservedValue = trial;
if (trial == 0)
{
cExpected = cPrior * cLike0;
cExpected = cPrior * cLike.ObservedValue[0];
}
else if (trial == 1)
{
cExpected = cPrior * cLike1;
cExpected = cPrior * cLike.ObservedValue[1];
}
else
{
@ -5223,6 +5249,49 @@ namespace Microsoft.ML.Probabilistic.Tests
}
}
[Fact]
public void CaseObservedConditionTest2()
{
Variable<int> b = Variable.New<int>().Named("b");
Bernoulli cPrior = new Bernoulli(0.1);
VariableArray<Bernoulli> cLike = Variable.Observed(new Bernoulli[] { new Bernoulli(0.2), new Bernoulli(0.3) }).Named("cLike");
Range item = new Range((b+1).Named("bPlus1")).Named("item");
VariableArray<bool> c = Variable.Array<bool>(item).Named("c");
c[item] = Variable.Bernoulli(0.1).ForEach(item);
using (Variable.Case(b, 0))
{
Variable.ConstrainEqualRandom(c[0], cLike[0]);
}
using (Variable.Case(b, 1))
{
Variable.ConstrainEqualRandom(c[1], cLike[1]);
}
InferenceEngine engine = new InferenceEngine();
BernoulliArray cExpected;
for (int iter = 0; iter < 2; iter++)
{
for (int trial = 0; trial < 3; trial++)
{
b.ObservedValue = trial;
if (trial == 0)
{
cExpected = new BernoulliArray(new Bernoulli[] { cPrior * cLike.ObservedValue[0] });
}
else if (trial == 1)
{
cExpected = new BernoulliArray(new Bernoulli[] { cPrior, cPrior * cLike.ObservedValue[1] });
}
else
{
cExpected = new BernoulliArray(new Bernoulli[] { cPrior, cPrior, cPrior });
}
IList<Bernoulli> cActual = engine.Infer<IList<Bernoulli>>(c);
Console.WriteLine("c = {0} should be {1}", cActual, cExpected);
Assert.True(cExpected.MaxDiff(cActual) < 1e-10);
}
}
}
[Fact]
public void IfObservedConstrainTrueElseTest()
{
@ -6330,18 +6399,16 @@ namespace Microsoft.ML.Probabilistic.Tests
public void CaseExitTest()
{
double priorB = 0.1;
double pXCond0 = 0.3;
double pXCond1 = 0.4;
Variable<int> b = Variable.Discrete(new double[] { priorB, 1 - priorB }).Named("b");
VariableArray<double> pX = Variable.Observed(new double[] { 0.3, 0.4 }).Named("pX");
Variable<int> b = Variable.Discrete(pX.Range, new double[] { priorB, 1 - priorB }).Named("b");
Variable<bool> x = Variable.New<bool>().Named("x");
using (Variable.Case(b, 0))
{
x.SetTo(Variable.Bernoulli(pXCond0));
x.SetTo(Variable.Bernoulli(pX[0]));
}
using (Variable.Case(b, 1))
{
x.SetTo(Variable.Bernoulli(pXCond1));
x.SetTo(Variable.Bernoulli(pX[1]));
}
InferenceEngine ie = new InferenceEngine();
@ -6349,7 +6416,7 @@ namespace Microsoft.ML.Probabilistic.Tests
Bernoulli xDist = ie.Infer<Bernoulli>(x);
// p(x,b) =propto (pb)^b (1-pb)^(1-b) [(pT)^x (1-pT)^(1-x)]^b [(pF)^x (1-pF)^(1-x)]^(1-b)
double postB = priorB;
double postX = priorB * pXCond0 + (1 - priorB) * pXCond1;
double postX = priorB * pX.ObservedValue[0] + (1 - priorB) * pX.ObservedValue[1];
Console.WriteLine("b = {0} (should be {1})", bDist, postB);
Console.WriteLine("x = {0} (should be {1})", xDist, postX);
Assert.True(System.Math.Abs(bDist[0] - postB) < 1e-4);

Просмотреть файл

@ -306,6 +306,9 @@ namespace Microsoft.ML.Probabilistic.Tests
}
}
/// <summary>
/// Tests that PointMassAnalysisTransform does not mark x as a ForwardPointMass
/// </summary>
[Fact]
public void PointMassAnalysisTest()
{

Просмотреть файл

@ -1030,6 +1030,8 @@ namespace Microsoft.ML.Probabilistic.Tests
};
}
// Randomly fails because of sensitivity to the message schedule
[Trait("Category", "OpenBug")]
[Fact]
public void PlusProductHierarchyTest()
{