locked
No update in model parameters after observing values and inference- infer.net RRS feed

  • Question

  • Hi,

    I have a problem with my model. I have a network of variables (which are genes' expressions in my case). It is somehow a dynamic Bayesian network. Value of each variable is a function of it's value in previous time step times alpha, plus a function of other variable values in previous time step times a beta variable. each variable's value is also dependent on some perturbations nodes.

    I have a w matrix, which I use to show, how each variable i, affects variable j. This weights are the same over all time steps. i.e, I use the same matrix in all layers of network.

    alpha and beta are selected randomly for the first layer.I have implemented this layered network as follows. But when I try to infer w, I get just a matrix with all elements being equal. It looks like that w is not connected to the model.

    Can any body help me in this case?

    Thank You

    Here is my code for reconstruction of the Bayesian network and inference prat:

    VariableArray<double> genesubarray = Variable.Array<double>(geneWeightRange).Named("genesubarray"); VariableArray<double> perturbEffectSubarray = Variable.Array<double>(perturbRange).Named("perturbEffectSubarray"); for (int layer = 0; layer < NumLayers.ObservedValue - 1; layer++) { using (ForEachBlock firstBlock = Variable.ForEach(geneRange)) {

    // timeSeriesData represents the network itself, i.e.

    // it is defined previously as: public VariableArray<VariableArray<double>, double[][]> timeSeriesData; Variable<double> selfEffect = (-(alpha[geneRange] * timeSeriesData[layer][geneRange])).Named("selfEffect_" + layer); VariableArray<double> weightSumArray = Variable.Array<double>(geneWeightRange).Named("weightSum_" + layer); genesubarray = Variable.Subarray(timeSeriesData[layer], indicesArray[geneRange]).Named("genesubarray_" + layer); // subset of genes which has effect on current gene weightSumArray[geneWeightRange] = (w[geneRange][geneWeightRange] * genesubarray[geneWeightRange]).Named("othersEffectArray_" + layer);//weights array multiply related genes, determine the effect of other genes on current gene perturbEffectSubarray = Variable.Subarray(pertData, pertIndices[geneRange]).Named("perturbEffectSubarray_" + layer); VariableArray<double> perturbationEffect = Variable.Array<double>(perturbRange).Named("perturbationEffect_" + layer); perturbationEffect[perturbRange] = genePertW[geneRange][perturbRange] * perturbEffectSubarray[perturbRange]; Variable<double> totalSum = (Variable.Sum(perturbationEffect).Named("sum_perturbationEffect_" + layer) + Variable.Sum(weightSumArray).Named("sum_weightSumArray_" + layer)).Named("totalSum_" + layer); //weightSum;// +perturbationEffectSum; double logisticEffect ; Variable<bool> condition = totalSum > 0; using (Variable.If(condition)) { logisticEffect=1; } using (Variable.IfNot(condition)) { logisticEffect = 0; } Variable<double> othersEffect = beta[geneRange] * (logisticEffect);// Variable.Logistic(Variable.Sum(weightSum));// Variable.Sum(weightSum); //Variable.Logistic(innerproduct); timeSeriesData[layer + 1][geneRange] = ( - selfEffect).Named("timeSeriesData_" + layer); } }//for each time layer if (inferenceEngine == null) { inferenceEngine = new InferenceEngine(); } var wMsg = Variable.Array(Variable.Array<Gaussian>(geneWeightRange), geneRange).Named("wMsg"); wMsg[geneRange][geneWeightRange] = Variable.Observed(Gaussian.Uniform()).ForEach(geneRange, geneWeightRange); Variable.ConstrainEqualRandom(w[geneRange][geneWeightRange], wMsg[geneRange][geneWeightRange]); w[geneRange][geneWeightRange].AddAttribute(QueryTypes.Marginal); // or w? w[geneRange][geneWeightRange].AddAttribute(QueryTypes.MarginalDividedByPrior); var wMarginal = new Gaussian[NumGenes.ObservedValue][]; for (int i = 0; i < NumGenes.ObservedValue; i++) { wMarginal[i] = new Gaussian[NumGenes.ObservedValue - 1]; for (int j = 0; j < wMarginal[i].Length; j++) { wMarginal[i][j] = Gaussian.Uniform(); } } Console.WriteLine("************** INFERENCE ************ "); for (int experiment = 0; experiment < dataList.Count; experiment++) { information = dataList.ElementAt(experiment).Item1; Console.WriteLine("Number of time points: " + information.Item1.Length); dataMatrix2 = dataList.ElementAt(experiment).Item2; timepoints = information.Item2; perturbations = intarraytodoublearray(information.Item1); dataMatrix = new double[dataMatrix2.Length - 1][]; for (int i = 0; i < dataMatrix.Length; i++) { dataMatrix[i] = new double[dataMatrix2[i].Length]; for (int j = 0; j < dataMatrix[i].Length; j++) { dataMatrix[i][j] = dataMatrix2[i][j]; } } // dataMatrix is now ready timeSeriesData.ObservedValue = dataMatrix; pertData.ObservedValue = perturbations[experiment]; wMarginal = inferenceEngine.Infer<Gaussian[][]>(w); wMsg.ObservedValue = inferenceEngine.Infer<Gaussian[][]>(w, QueryTypes.MarginalDividedByPrior); writeFile(wMarginal, path + @"\data\output\wMarginal" + experiment + ".txt"); }// FOR EACH BATCH




    • Edited by RazinR Sunday, August 10, 2014 12:21 PM
    Sunday, August 10, 2014 12:20 PM

Answers