locked
error CS1034:Compiler limit exceeded RRS feed

  • Question

  • Hi everyone

    I'm using Infer.NET for a project in my university. Running a model i've done i got the following errors:

    Compiled model...done.

    ..path_To_generated_code\Model.EP.cs(1150 , 16777214) : error CS1034: Compiler limit exceeded: Line cannot exceed 16777214 characters

    ....path_To_generated_code\Model.EP.cs(1, 1) : error CS1038: #endregion directive expected.

    What kind of error are these?? It seems that the compiler is not able to read the created code because the dimensions of the file.

    How can i fix these??

    Thank you in advance

    Marco

    P.s I can also provide the generated model if needed.

    Wednesday, July 31, 2013 9:46 AM

Answers

  • The problem is that your data arrays are being embedded in the generated code.  Try to use Variable.Observed for large arrays instead of Variable.Constant, since constants are embedded in the code.
    • Marked as answer by MarcoASDF Thursday, August 1, 2013 2:39 PM
    Thursday, August 1, 2013 7:10 AM
    Owner
  • What is the error that you get when IsReadOnly=false?  Your idea of using OptimiseForVariables should also work.
    • Marked as answer by MarcoASDF Thursday, August 1, 2013 2:39 PM
    Thursday, August 1, 2013 11:59 AM
    Owner
  • The problem is that you are using the same range for both dimensions of the RBPKernel array.  You need to use separate ranges.  This can be done via range cloning as explained in Cloning ranges.
    • Marked as answer by MarcoASDF Thursday, August 1, 2013 2:39 PM
    Thursday, August 1, 2013 1:51 PM
    Owner

All replies

  • As a first step, can you send us the MSL code (engine.ShowMsl = true;). The MSL will print on the Console. You can send to infersup@microsoft.com.

    Wednesday, July 31, 2013 4:39 PM
    Owner
  • The problem is that your data arrays are being embedded in the generated code.  Try to use Variable.Observed for large arrays instead of Variable.Constant, since constants are embedded in the code.
    • Marked as answer by MarcoASDF Thursday, August 1, 2013 2:39 PM
    Thursday, August 1, 2013 7:10 AM
    Owner
  • Hi 

    Do you mean that i should declare this kind of variable as Variable.Observed or, according with the web userGuide, set Variable.IsReadOnly = false; ??

    Let me show you an example where i got this error: 

    Assume that Kernel is a known structure, with elements loaded by a file and so known and fixed ( it can be considered as part of a dataset, as the featureVector matrix for all the dataset items). The code below show its declaration and the way how it is filled.

    var Kernel = Variable.Array(Variable.Array<double>(RBP), (RBP)).Named("RBPKernel");
    
    LoadKernel(Kernel, numRBPs, RBPsMap, "RBP");
    
    
    ...
    
    static private void LoadKernel(VariableArray<VariableArray<double>, double[][]> Kernel, int numElements, 
                                           Dictionary<int, string> Map, string type)
            {
    
                string path;
                if(type == "RBP")
                    path = "../../files/commonInteractions.txt";
                else
                    path = "../../files/geneSImatrix.txt";
    
                using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                using (BufferedStream bs = new BufferedStream(fs))
                using (StreamReader sr = new StreamReader(bs))
                {
                    char[] sep = { '\t', ' ' };
    
                    double[][] tmpKernel = new double[numElements][];
    
                    string myStr = "";
                    string headerline = sr.ReadLine().Replace("#=", "");
                    string[] elements = headerline.Split(sep);
                    int index = 0;
                    while ((myStr = sr.ReadLine()) != null)
                    {
                        int ElementIndex = ((int)Map.FirstOrDefault(x => x.Value == elements[index]).Key) - 1;
    
                        string[] mySplitStr = myStr.Split(sep);
    
                        int j = 0;
                        foreach (string c in mySplitStr)
                        {
                            tmpKernel[ElementIndex][j] = Convert.ToDouble(mySplitStr[j].Replace('.', ','));
                            j += 1;
                        }
                        index += 1;
                    }
                    sr.Close();
                    Kernel.ObservedValue = tmpKernel;
                }
            }


    I need to use the Infer.NET definition(VariableArray...) because this structure is combined with another that is not fixed and that is used by the model to make the infence:

    var RBPTraits = Variable.Array(Variable.Array<double>(trait), RBP).Named("RBPTraits");
    
    ...
    
     var RBPKernelPrior = Variable.Array(Variable.Array<double>(RBP), trait).Named("RBPKernelPrior");
    
    ...
    
    RBPKernelPrior[trait][RBP] = Variable.GaussianFromMeanAndPrecision(RBPKernelMean[RBP], RBPKernelPrec[RBP]).ForEach(trait);
    
    ...
    
    RBPTraits[RBP][trait] = Variable.GaussianFromMeanAndPrecision(
                                              Variable.InnerProduct(Variable.Vector(RBPKernel[RBP]), Variable.Vector(RBPKernelPrior[trait])),1);

    The last line show the need to use Infer.NET structure in order to index it with ranges.

    So the problem is the following: if i don't set the Variable.IsOnlyRead paramenter to True, the system try to make the inference and compute the marginal also for the Kernel structure that, obviously, lead to an error. 

    The solution I've thought is to use the   "engine.OptimiseForVariables = new VariableArray<double>[] ..." without putting into it the Kernel Variable. 

    Is this a right way to use Infer.NET and the  "engine.OptimiseForVariables" option? 

    Thank you for your time

    Marco

    Thursday, August 1, 2013 10:47 AM
  • What is the error that you get when IsReadOnly=false?  Your idea of using OptimiseForVariables should also work.
    • Marked as answer by MarcoASDF Thursday, August 1, 2013 2:39 PM
    Thursday, August 1, 2013 11:59 AM
    Owner
  • This is the error:

    c:\Users\user\Documents\Visual Studio 11\Projects\BinaryModelGENE-EXP4_SideInformation\BinaryModelGENE-EXP4\bin\Debug\GeneratedSource\Model_EP.cs(2402,12) : error CS1502: The best overloaded method match for 'MicrosoftResearch.Infer.Distributions.DistributionStructArray<MicrosoftResearch.Infer.Distributions.Gaussian,double>.DistributionStructArray(int, System.Func<int,MicrosoftResearch.Infer.Distributions.Gaussian>)' has some invalid arguments
    c:\Users\user\Documents\Visual Studio 11\Projects\BinaryModelGENE-EXP4_SideInformation\BinaryModelGENE-EXP4\bin\Debug\GeneratedSource\Model_EP.cs(2402,61) : error CS1503: Argument 2: cannot convert from 'anonymous method' to 'System.Func<int,MicrosoftResearch.Infer.Distributions.Gaussian>'
    c:\Users\user\Documents\Visual Studio 11\Projects\BinaryModelGENE-EXP4_SideInformation\BinaryModelGENE-EXP4\bin\Debug\GeneratedSource\Model_EP.cs(2402,70) : error CS0136: A local variable named 'RBP' cannot be declared in this scope because it would give a different meaning to 'RBP', which is already used in a 'parent or current' scope to denote something else
    c:\Users\user\Documents\Visual Studio 11\Projects\BinaryModelGENE-EXP4_SideInformation\BinaryModelGENE-EXP4\bin\Debug\GeneratedSource\Model_EP.cs(2408,12) : error CS1502: The best overloaded method match for 'MicrosoftResearch.Infer.Distributions.DistributionStructArray<MicrosoftResearch.Infer.Distributions.Gaussian,double>.DistributionStructArray(int, System.Func<int,MicrosoftResearch.Infer.Distributions.Gaussian>)' has some invalid arguments
    c:\Users\user\Documents\Visual Studio 11\Projects\BinaryModelGENE-EXP4_SideInformation\BinaryModelGENE-EXP4\bin\Debug\GeneratedSource\Model_EP.cs(2408,63) : error CS1503: Argument 2: cannot convert from 'anonymous method' to 'System.Func<int,MicrosoftResearch.Infer.Distributions.Gaussian>'
    c:\Users\user\Documents\Visual Studio 11\Projects\BinaryModelGENE-EXP4_SideInformation\BinaryModelGENE-EXP4\bin\Debug\GeneratedSource\Model_EP.cs(2408,72) : error CS0136: A local variable named 'gene' cannot be declared in this scope because it would give a different meaning to 'gene', which is already used in a 'parent or current' scope to denote something else


    and these are the lines of the errors in the file Model_EP.cs

    this.RBPKernel_marginal = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(68, delegate(int RBP) {
    				return new DistributionStructArray<Gaussian,double>(68, delegate(int RBP) {
    					return Gaussian.Uniform();
    				});
    this.RBPKernel_marginal = Distribution.SetPoint<DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>,double[][]>(this.RBPKernel_marginal, this.rBPKernel);
    			this.geneKernel_marginal = new DistributionRefArray<DistributionStructArray<Gaussian,double>,double[]>(3468, delegate(int gene) {
    				return new DistributionStructArray<Gaussian,double>(3468, delegate(int gene) {
    					return Gaussian.Uniform();
    				});

    The second and the seventh lines are the lines 2402 and 2408 in the generated Code

    RBPKernel and geneKernel are the structure that I called Kernel in the previous post
    • Edited by MarcoASDF Thursday, August 1, 2013 12:35 PM
    Thursday, August 1, 2013 12:32 PM
  • The problem is that you are using the same range for both dimensions of the RBPKernel array.  You need to use separate ranges.  This can be done via range cloning as explained in Cloning ranges.
    • Marked as answer by MarcoASDF Thursday, August 1, 2013 2:39 PM
    Thursday, August 1, 2013 1:51 PM
    Owner
  • Thank you a lot for your answers. I really appreciate it.
    Best Regards
    Marco
    Thursday, August 1, 2013 2:38 PM