Граф коммитов

452 Коммитов

Автор SHA1 Сообщение Дата
Ivan Korostelev 7bd784335d
Replace ReadOnlyArray with ImmutableArray look-alike (#217)
`System.Collections.Immutable` has `ImmutableArray` that serves the same purpose as
`ReadOnlyArray` but has different API. This type is available (without extra dependencies)
only in netcore, so can't be used in Infer.NET which has to support netframework.
Until netframework support can be dropped reimplement a subset of `ImmutableArray`
in Infer.NET codebase.
2020-02-29 09:49:41 +00:00
Ivan Korostelev ffd4680f57 Add non-generic IDistribution interface 2020-02-11 16:03:25 +00:00
Jonathan Tims ed4bebbb7e
Restore documentation generation (#214)
makeApiDocs.ps1 uses newer docfx version, and copies build directory because it is now required by project files to build.
toc.yml references md files instead of html files.
Compiler escapes the < and > symbols in XML doc.
Updated and fixed broken factor documentation.
Tools.PrepareSource only processes lines that start with ///

Co-authored-by: Tom Minka <8955276+tminka@users.noreply.github.com>
2020-02-07 16:28:22 +00:00
msdmkats 5cd2718883
Special functions use auto-generated truncated series (#207)
* Python tool to generate expressions for truncated series.
* Using the generated series in special functions
* Test projects set Optimize=true in Release configuration

Co-authored-by: Tom Minka <8955276+tminka@users.noreply.github.com>
2020-02-07 12:57:20 +00:00
John Guiver 053bac1751
Log probability override in DiscreteChar (#206)
Log probability override for Discrete char
2020-01-13 14:27:31 +00:00
Jean-Sylvain Boige 000818158c ImageClassifier crashes on a French OS (#209)
* Use InvariantCulture when saving/loading features.
2020-01-07 22:10:37 +00:00
Tom Minka 75ae71f2b5
DependencyAnalysisTransform fix (#211)
Fixed an issue where DependencyAnalysisTransform would give incorrect SkipIfUniform dependencies, causing statements to be incorrectly pruned from the generated code.
Removed FactorManager.AnyItem. Added FactorManager.All.
GaussianProductOp.AAverageConditional handles uniform B.
MMath.ChooseLn handles more cases.
2020-01-07 20:22:52 +00:00
Ivan Korostelev 54eea9b343
Make CheckStateCount() behave as expected (#210) 2020-01-07 18:23:12 +00:00
msdmkats 482f807bab
Power series abstraction (#201)
- Introduced an abstraction for truncated power series
- Introduced an abstraction for power series
- Made [Di|Tri|Tetra]Gamma[Ln] use it
- Added internal interface to recompute power series used in MMath and make them longer/shorter depending on the necessary precision. It can be used in tests.

Currently, power series computation is rather primitive (cut-off some precomputed series at a point where it used to be cut as long as the precision in <= 53, don't cut-off otherwise).
2019-12-17 17:13:31 +03:00
Tom Minka 6900d2862c Monty Hall example updates the displayed probabilities upon reset 2019-12-10 19:36:44 +00:00
Tom Minka 54be5f2eda
DefaultVisualizer writes graphs in both Dot and DGML format (#202)
* Examples Browser saves factor graphs to folder in addition to displaying.
2019-12-04 20:56:39 +00:00
Jonathan Tims daa1058627 Use license and icon rather than licenseUrl and iconUrl which are now deprecated. (#200)
o Marked each non-packing assembly as "IsPackage=false" because the default is to package the assemblies. Done this via a common.props import.
o Switched to using integrated CSProj NuGet properties. Done this via a nuget-properties.props import.
o Switched to using msbuild in release.yml rather than nuget, since nuget.exe does not support the new spec.
o Added a LearnersNuGet project to be the "csproj" host for the learners nuspec (since the learners nuget does not correspond to any particular existing csproj project).
o Updated ClickThroughModel.csproj and ClinicalTrial.csproj and Image_Classifier.cs and MontyHall.csproj to new-style csprojs because otherwise new msbuild commands reject them.
o Made release.yml msbuild calls multiprocess to speed them up.
o Factored out some common properties into the common.props file.
2019-12-04 14:39:03 +00:00
Tom Minka 782575a99a
Merge pull request #198 from dotnet/jonathantims-signing
Fix to signing
2019-11-26 15:44:09 +00:00
Jonathan Tims ed7735e755
Fix to signing 2019-11-26 11:35:38 +00:00
Tom Minka 4be5bb42de Signed build doesn't re-run tests.
Updated signing to MicroBuild.Core.0.3.1
Fixed compiler warning
2019-11-22 17:17:00 +00:00
Tom Minka 57c888024c
Improved GammaPower implementation (#195)
GammaPower creates a point mass whenever Rate would be infinite.
Added GammaPower.FromMeanAndMeanLog.
Improved numerical accuracy of GammaPower.GetLogProb, GetMean, and GetMode.
Added GammaPowerEstimator
GammaProductOp supports GammaPower distributions.
GammaProductOp handles uniform message from product.
Added GammaPowerProductOp_Laplace
Fixed PowerOp for GammaPower distributions.
Added PlusGammaOp for GammaPower distributions.
MMath.GammaUpper has an unregularized option.
Added TruncatedGamma.GetMeanPower.
PowerOp supports TruncatedGamma.
Swapped the argument order of (internal) MMath.LargestDoubleProduct and LargestDoubleRatio.
2019-11-13 14:31:12 +00:00
Ivan Korostelev d6e7d5b975
Make MaxStateCount overrides thread local (#194)
UnlimitedStatesComputation() is used temporary to alter maximal size of automaton
which is defined my MaxStateCount. Using it from different threads could mess up the limit.
Now each threads gets its own limit.

Also, the default MaxStateCount limit is increased to 300k, because that is what the biggest String inference customer uses.
2019-11-07 16:44:54 +00:00
Ivan Korostelev 470ae84c36
Simplify `CombinedRanges` (#193)
`CombinedRanges` method was actually 2 completely different methods which are now split in 2
  (and simplified a little):
  - `IntersectRanges` - returns only segments where both probabilities are non-zero
  - `CombineRanges` - returns all segments
2019-11-05 16:24:18 +00:00
Ivan Korostelev fe41d89eba
Fix DiscreteChar.Complement() & Simplify ranges operations (#192)
After recent refactoring that removed `ProbabilityOutsideRanges`, `DiscreteChar.Complement()` 
started to work incorrectly in case ranges were going one after another.

For example DiscreteChar.Point('\0').Complement() was equal to uniform distribution, i.e. still included the \0 char.
2019-11-05 14:42:28 +00:00
Ivan Korostelev 1f54bc32f7
Precise sums in automaton determinization (#189)
Automaton determinization procedure used to keep a running total of weights for each state.
That sum was maintained by adding weights for next open segment and substracting weights
for closed segments. If the weights of segments differ a lot (LogValue difference is bigger than 100)
than due to numerical issues sum could become zero after subtraction which lead to dropping
of transition and automaton language truncation.

Now the weights sum is recalculated from scratch each time. It also results in loss of precision,
but it is important that the precision is lost only for very large weights, not very small ones. So
no accidental zeroing of weights is happening and language is not truncated.

It doesn't really impact runtime because `WeightedStateSet` construction enumerated all weights
anyway (to normalize them), so in the worst case slowdown is at most constant.
And in average case (where we maintain  1 or 2 destination states per transition) the runtime
is actually better due to lower constant costs.

New test (`AutomatonTests.Determinize11`) was added, it used to fail with previous implementation.

To make this change I had to rewrite code substantially which in my opinion makes it easier to follow:
- The determinization procedure now makes use of `CharSegmentsEnumerator` helper class
  which enumerates over all char segments from multiple char distributions. These segments are
  non-overlapping.
- `WeightedStateSetBuilder` now handles duplicate state indices in `Add()` call. Previously deduplication
  had to happen via accumulating sum in `Dictionary<int, WeightSum>`
2019-10-29 18:18:50 +00:00
Ivan Korostelev 419419327d
Remove DiscreteChar.ProbabilityOutsideRanges (#188)
A lot of code existed that had to treat `ProbabilityOutsideRanges` in a special way.
Now in cases where `ProbabilityOutsideRanges` was non-zero missing ranges are added to
cove all char domain.

`ProbabilityOutsideRanges` had 1 useful property: it needed 2 times less ranges for representing distributions distributions covering whole domain

This property is never used in real code. (And even if it did, it would be in a very few places), so reducing code complexity trumps small performance/space gain.
2019-10-29 09:46:57 +00:00
Ivan Korostelev b74d02b98d
Add ability to check if DiscreteChar was initialized (#185)
`DiscreteChar` is basically a wrapper struct around a single pointer.
This pointer can be null if DiscreteChar is created using `default(DiscreteChar)`.
`IsInitialized` method is added which checks whether this pointer is not null.

It is useful to implement caching of `DiscreteChars` using an array `DiscreteChar[] cache`.
Uninitialized cached entries can be found using `cache[index].IsInitialized`, previously
we had to use `Nullable<DiscreteChar>[] cache` which has a measurable size overhead.
2019-10-16 17:01:23 +01:00
Tom Minka 4103cb3dbe
Added GaussianFromMeanAndVarianceOp_PointVariance (#184)
* Added GaussianFromMeanAndVarianceOp_PointVariance

* Gamma.FromDerivatives allows x=0
2019-10-04 19:04:00 +01:00
Tom Minka f44d7f3a26
Gaussian.GetMean throws if Precision == 0, instead of returning 0. (#183)
ExpOp.ExpAverageConditional correctly handles improper d.
InnerQuantiles/OuterQuantiles check for an empty quantiles array.
2019-10-03 19:47:01 +01:00
Bruno Fernandes c4966e3037 Increase quality band of string ops to 'Preview' 2019-10-01 20:52:55 +01:00
Dmitry Voitsekhovskiy fdae2ea84a Increase job timeout for nightly-netcore 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy 0ff9f0b13e Using more succinct syntax for job timeout 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy 9118d1c360 Added 2hrs timeout to pr-netcore 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy 51c4a6035a Updated display names 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy 7d650ecea6 Fixed job name 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy 876173d140 Fixed job names 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy de8e22886d Added condition to Package and Publish job 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy be5383dfb8 Commented queue 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy 29eda6edea Nightly windows pipeline split into 4 jobs 2019-10-01 18:40:53 +01:00
Dmitry Voitsekhovskiy 4d6e13fe75 Increased job timeouts 2019-10-01 18:40:53 +01:00
Tom Minka 625228bc40 Gaussian.GetLogProb is more accurate for large precision.
DoubleIsBetweenOp fix.
MMath.LargestDoubleSum works in 32-bit.
2019-09-21 20:02:10 +01:00
Tom Minka cfc8128143 MMath.LargestDoubleProduct is more efficient 2019-09-21 20:02:10 +01:00
Tom Minka a9f16b20bb
Merge pull request #163 from dotnet/InnerProduct
Added GatedInnerProductVectorTest and missing overloads of InnerProductOp
2019-09-21 14:25:13 +01:00
Tom Minka e642655221
Merge branch 'master' into InnerProduct 2019-09-21 14:25:03 +01:00
Tom Minka cfe2f72f98
Merge pull request #168 from dotnet/ivkorost/remove-try-determinize-assert
Remove wrong Debug.Assert()
2019-09-18 17:57:04 +01:00
Tom Minka a11a745a84
Merge branch 'master' into ivkorost/remove-try-determinize-assert 2019-09-18 15:49:07 +01:00
Tom Minka f5caba87b0
Merge pull request #167 from dotnet/ivkorost/automaton-less-enums
Replace custom enums with bool?
2019-09-18 15:48:33 +01:00
Ivan Korostelev 89b5ac03f4 Spelling 2019-09-18 13:13:42 +01:00
Ivan Korostelev b7a6c33393 Spelling 2019-09-18 13:12:12 +01:00
Ivan Korostelev cfe60e308a Remove wrong Debug.Assert()
String automaton determinization supports infinite weights.
2019-09-18 11:17:15 +01:00
Ivan Korostelev 8ad7d78d7a Fix quoting 2019-09-18 10:38:03 +01:00
Ivan Korostelev c4c36c1f4b Replace custom enums for caches with bool? type.
Also, fix assert in Automaton.DataContainer.With()
2019-09-18 10:35:32 +01:00
Yordan Zaykov 75d9fe687e
Merge pull request #166 from dotnet/ivkorost/is-zero-explicit-stack
Use explicit stack in Automaton.IsZero()
2019-09-17 16:02:12 +01:00
Ivan Korostelev 1893477580 Fix comments 2019-09-17 14:02:06 +01:00
Ivan Korostelev 2d5ce49ea3 Add a test with large automaton 2019-09-17 13:58:23 +01:00