зеркало из https://github.com/dotnet/infer.git
LDA and RobustGaussianProcess support .NET Core (#286)
* Add more generated files to exclusion list * RobustGaussianProcess uses OxyPlot.Wpf only on Windows Co-authored-by: Tom Minka <8955276+tminka@users.noreply.github.com>
This commit is contained in:
Родитель
bc953687bf
Коммит
52cc9b2c78
|
@ -260,3 +260,6 @@ _site/
|
|||
|
||||
**/GeneratedSource
|
||||
**/__pycache__
|
||||
*.png
|
||||
/src/Examples/Crowdsourcing/Results
|
||||
/src/Examples/ImageClassifier/Images/Features.txt
|
||||
|
|
|
@ -52,6 +52,10 @@
|
|||
<ProjectReference Include="..\..\Compiler\Compiler.csproj" />
|
||||
<ProjectReference Include="..\..\Runtime\Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Shared\SharedAssemblyFileVersion.cs" />
|
||||
|
|
|
@ -151,20 +151,16 @@ namespace LDAExample
|
|||
// Train the model - we will also get rough estimates of execution time and memory
|
||||
Dirichlet[] postTheta, postPhi;
|
||||
GC.Collect();
|
||||
#if NETFULL
|
||||
PerformanceCounter memCounter = new PerformanceCounter("Memory", "Available MBytes");
|
||||
float preMem = memCounter.NextValue();
|
||||
#endif
|
||||
stopWatch.Reset();
|
||||
stopWatch.Start();
|
||||
double logEvidence = model.Infer(trainWordsInTrainDoc, alpha, beta, out postTheta, out postPhi);
|
||||
stopWatch.Stop();
|
||||
#if NETFULL
|
||||
float postMem = memCounter.NextValue();
|
||||
double approxMB = preMem - postMem;
|
||||
GC.KeepAlive(model); // Keep the model alive to this point (for the memory counter)
|
||||
Console.WriteLine(String.Format("Approximate memory usage: {0:F2} MB", approxMB));
|
||||
#endif
|
||||
Console.WriteLine(String.Format("Approximate execution time (including model compilation): {0} seconds", stopWatch.ElapsedMilliseconds / 1000));
|
||||
|
||||
// Calculate average log evidence over total training words
|
||||
|
|
|
@ -57,8 +57,7 @@ namespace RobustGaussianProcess
|
|||
|
||||
// Infer the posterior Sparse GP
|
||||
SparseGP sgp = engine.Infer<SparseGP>(gaussianProcessRegressor.F);
|
||||
|
||||
#if NETFULL
|
||||
#if WINDOWS
|
||||
string datasetName = useSynthetic ? "Synthetic" : "AIS";
|
||||
Utilities.PlotPredictions(sgp, trainingInputs, trainingOutputs, useStudentTLikelihood, datasetName);
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Configurations>Debug;Release;DebugFull;DebugCore;ReleaseFull;ReleaseCore</Configurations>
|
||||
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(IsWindows)'=='true'">
|
||||
<DefineConstants>WINDOWS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(Configuration)'=='DebugFull' OR '$(Configuration)'=='ReleaseFull'">
|
||||
|
@ -26,14 +30,6 @@
|
|||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<DefineConstants>$(DefineConstants);NETCORE;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461'">
|
||||
<DefineConstants>$(DefineConstants);NETFULL</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU' OR '$(Configuration)|$(Platform)'=='DebugFull|AnyCPU' OR '$(Configuration)|$(Platform)'=='DebugCore|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
|
@ -64,8 +60,8 @@
|
|||
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$(DefineConstants.Contains('NETFULL'))">
|
||||
<PackageReference Include="OxyPlot.Wpf" Version="1.0.0" />
|
||||
<ItemGroup Condition="'$(IsWindows)'=='true'">
|
||||
<PackageReference Include="OxyPlot.Wpf" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -9,7 +9,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
#if NETFULL
|
||||
#if WINDOWS
|
||||
using OxyPlot.Wpf;
|
||||
using OxyPlot;
|
||||
using System.Threading;
|
||||
|
@ -113,7 +113,7 @@ namespace RobustGaussianProcess
|
|||
return engine;
|
||||
}
|
||||
|
||||
#if NETFULL
|
||||
#if WINDOWS
|
||||
public static void PlotGraph(PlotModel model, string graphPath)
|
||||
{
|
||||
// Required for plotting
|
||||
|
|
Загрузка…
Ссылка в новой задаче