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
**/__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