зеркало из 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
|
**/GeneratedSource
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
|
*.png
|
||||||
|
/src/Examples/Crowdsourcing/Results
|
||||||
|
/src/Examples/ImageClassifier/Images/Features.txt
|
||||||
|
|
|
@ -53,6 +53,10 @@
|
||||||
<ProjectReference Include="..\..\Runtime\Runtime.csproj" />
|
<ProjectReference Include="..\..\Runtime\Runtime.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.7.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\Shared\SharedAssemblyFileVersion.cs" />
|
<Compile Include="..\..\Shared\SharedAssemblyFileVersion.cs" />
|
||||||
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs" />
|
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs" />
|
||||||
|
|
|
@ -151,20 +151,16 @@ namespace LDAExample
|
||||||
// Train the model - we will also get rough estimates of execution time and memory
|
// Train the model - we will also get rough estimates of execution time and memory
|
||||||
Dirichlet[] postTheta, postPhi;
|
Dirichlet[] postTheta, postPhi;
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
#if NETFULL
|
|
||||||
PerformanceCounter memCounter = new PerformanceCounter("Memory", "Available MBytes");
|
PerformanceCounter memCounter = new PerformanceCounter("Memory", "Available MBytes");
|
||||||
float preMem = memCounter.NextValue();
|
float preMem = memCounter.NextValue();
|
||||||
#endif
|
|
||||||
stopWatch.Reset();
|
stopWatch.Reset();
|
||||||
stopWatch.Start();
|
stopWatch.Start();
|
||||||
double logEvidence = model.Infer(trainWordsInTrainDoc, alpha, beta, out postTheta, out postPhi);
|
double logEvidence = model.Infer(trainWordsInTrainDoc, alpha, beta, out postTheta, out postPhi);
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
#if NETFULL
|
|
||||||
float postMem = memCounter.NextValue();
|
float postMem = memCounter.NextValue();
|
||||||
double approxMB = preMem - postMem;
|
double approxMB = preMem - postMem;
|
||||||
GC.KeepAlive(model); // Keep the model alive to this point (for the memory counter)
|
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));
|
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));
|
Console.WriteLine(String.Format("Approximate execution time (including model compilation): {0} seconds", stopWatch.ElapsedMilliseconds / 1000));
|
||||||
|
|
||||||
// Calculate average log evidence over total training words
|
// Calculate average log evidence over total training words
|
||||||
|
|
|
@ -57,8 +57,7 @@ namespace RobustGaussianProcess
|
||||||
|
|
||||||
// Infer the posterior Sparse GP
|
// Infer the posterior Sparse GP
|
||||||
SparseGP sgp = engine.Infer<SparseGP>(gaussianProcessRegressor.F);
|
SparseGP sgp = engine.Infer<SparseGP>(gaussianProcessRegressor.F);
|
||||||
|
#if WINDOWS
|
||||||
#if NETFULL
|
|
||||||
string datasetName = useSynthetic ? "Synthetic" : "AIS";
|
string datasetName = useSynthetic ? "Synthetic" : "AIS";
|
||||||
Utilities.PlotPredictions(sgp, trainingInputs, trainingOutputs, useStudentTLikelihood, datasetName);
|
Utilities.PlotPredictions(sgp, trainingInputs, trainingOutputs, useStudentTLikelihood, datasetName);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<Configurations>Debug;Release;DebugFull;DebugCore;ReleaseFull;ReleaseCore</Configurations>
|
<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>
|
</PropertyGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="'$(Configuration)'=='DebugFull' OR '$(Configuration)'=='ReleaseFull'">
|
<When Condition="'$(Configuration)'=='DebugFull' OR '$(Configuration)'=='ReleaseFull'">
|
||||||
|
@ -26,14 +30,6 @@
|
||||||
</Otherwise>
|
</Otherwise>
|
||||||
</Choose>
|
</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'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU' OR '$(Configuration)|$(Platform)'=='DebugFull|AnyCPU' OR '$(Configuration)|$(Platform)'=='DebugCore|AnyCPU'">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
|
@ -64,8 +60,8 @@
|
||||||
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs" />
|
<Compile Include="..\..\Shared\SharedAssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="$(DefineConstants.Contains('NETFULL'))">
|
<ItemGroup Condition="'$(IsWindows)'=='true'">
|
||||||
<PackageReference Include="OxyPlot.Wpf" Version="1.0.0" />
|
<PackageReference Include="OxyPlot.Wpf" Version="2.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -9,7 +9,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
#if NETFULL
|
#if WINDOWS
|
||||||
using OxyPlot.Wpf;
|
using OxyPlot.Wpf;
|
||||||
using OxyPlot;
|
using OxyPlot;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -113,7 +113,7 @@ namespace RobustGaussianProcess
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETFULL
|
#if WINDOWS
|
||||||
public static void PlotGraph(PlotModel model, string graphPath)
|
public static void PlotGraph(PlotModel model, string graphPath)
|
||||||
{
|
{
|
||||||
// Required for plotting
|
// Required for plotting
|
||||||
|
|
Загрузка…
Ссылка в новой задаче