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:
Andrii Kurdiumov 2020-09-08 16:46:38 +06:00 коммит произвёл GitHub
Родитель bc953687bf
Коммит 52cc9b2c78
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 16 добавлений и 18 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -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