├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── ROADMAP.md ├── Sigma.Core.Monitors.WPF.Tests ├── Model │ └── UI │ │ └── TestGridSize.cs ├── Properties │ └── AssemblyInfo.cs ├── Resources │ ├── Entypo-license.txt │ ├── Entypo.ttf │ ├── Icons.xaml │ ├── IconsNonShared.xaml │ └── WindowsIcons-license.txt ├── Sigma.Core.Monitors.WPF.Tests.csproj ├── View │ └── TestUIWrapper.cs ├── WPFMonitorTest.cs ├── app.config └── packages.config ├── Sigma.Core.Monitors.WPF ├── App.config ├── App.xaml ├── App.xaml.cs ├── Model │ ├── SigmaGrid │ │ └── GridExtensions.cs │ └── UI │ │ ├── Resources │ │ ├── FontResource.xaml │ │ ├── MaterialDesignColours.xaml │ │ ├── MaterialDesignValues.cs │ │ └── UIResources.cs │ │ ├── StatusBar │ │ └── StatusBarLegendInfo.cs │ │ └── Windows │ │ └── GridSize.cs ├── Panels │ ├── Charts │ │ ├── AccuracyPanel.cs │ │ ├── CartesianChartPanel.cs │ │ ├── ChartPanel.cs │ │ ├── Definitions │ │ │ └── IPointVisualiser.cs │ │ ├── LineChartPanel.cs │ │ └── TrainerChartPanel.cs │ ├── Controls │ │ ├── BitmapPanel.cs │ │ ├── ControlPanel.cs │ │ ├── DrawPanel.cs │ │ └── RectanglePanel.cs │ ├── DataGrids │ │ ├── CustomDataGridPanel.cs │ │ ├── SigmaDataGridPanel.cs │ │ └── SimpleDataGridPanel.cs │ ├── Games │ │ └── TicTacToe │ │ │ ├── TicTacToeButton.cs │ │ │ ├── TicTacToeField.xaml │ │ │ ├── TicTacToeField.xaml.cs │ │ │ └── TicTacToePanel.cs │ ├── GenericPanel.cs │ ├── IInputPanel.cs │ ├── IOutputPanel.cs │ ├── Logging │ │ ├── LogDataGridPanel.cs │ │ └── LogTextPanel.cs │ ├── Optimisations │ │ └── BitmapHookPanel.cs │ ├── Parameterisation │ │ └── ParameterPanel.cs │ ├── SigmaPanel.cs │ └── XamlPanel.cs ├── Properties │ ├── Annotations.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.de-DE.Designer.cs │ ├── Resources.de-DE.resx │ ├── Resources.en-GB.Designer.cs │ ├── Resources.en-GB.resx │ ├── Resources.en-US.Designer.cs │ ├── Resources.en-US.resx │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ ├── Entypo-license.txt │ ├── Entypo.ttf │ ├── Icons.xaml │ ├── IconsNonShared.xaml │ ├── WindowsIcons-license.txt │ └── icons │ │ ├── sigma.ico │ │ └── sigma_256x256.png ├── Sigma.Core.Monitors.WPF.csproj ├── Sigma.Core.Monitors.WPF.licenseheader ├── Sigma.Core.Monitors.WPF.nuspec ├── Sigma.Core.Monitors.WPF.targets ├── Themes │ ├── Generic.xaml │ └── Styles │ │ ├── CustomControls │ │ ├── DrawCanvasDark.xaml │ │ └── DrawCanvasLight.xaml │ │ ├── DarkStyle.xaml │ │ ├── LightStyle.xaml │ │ ├── LiveCharts │ │ └── AxisDark.xaml │ │ ├── MaterialDesign │ │ └── MaterialDesignExtensionStyles.xaml │ │ ├── Panels │ │ └── DataGrid.xaml │ │ ├── SigmaGrid │ │ ├── CardColoursDark.xaml │ │ ├── CardColoursLight.xaml │ │ └── CardStyle.xaml │ │ ├── SigmaStatusBar │ │ ├── StatusBarLegendStyle.xaml │ │ └── TaskVisualizerStyle.xaml │ │ ├── SigmaStyles.xaml │ │ ├── TitleBar │ │ ├── MenuStyle.xaml │ │ ├── MenuStyleDark.xaml │ │ ├── MenuStyleLight.xaml │ │ ├── SigmaAboutBoxStyle.xaml │ │ └── SigmaAboutBoxStyleDark.xaml │ │ └── Window │ │ └── DialogHostStyle.xaml ├── Utils │ ├── AttributeUtils.cs │ ├── BindUtils.cs │ ├── ChartPanelPerformance.cs │ ├── ChartPanelVisualisation.cs │ ├── Converters │ │ └── InverseBooleanConverter.cs │ ├── Defaults │ │ └── MNIST │ │ │ └── MnistTargetMaximisationPanel.cs │ ├── RelayCommand.cs │ ├── WindowUtils.cs │ └── WriteableBitmapUtils.cs ├── View │ ├── Colours │ │ ├── ColourManager.cs │ │ └── IColourManager.cs │ ├── CustomControls │ │ ├── GridLayout.cs │ │ ├── Panels │ │ │ ├── Control │ │ │ │ ├── DrawCanvas.cs │ │ │ │ ├── RectangleCanvas.cs │ │ │ │ ├── SigmaPlaybackControl.Designer.cs │ │ │ │ ├── SigmaPlaybackControl.cs │ │ │ │ └── SigmaPlaybackControlGeneric.xaml │ │ │ └── TicTacToe │ │ │ │ └── TicTacToeButtonGeneric.xaml │ │ ├── StatusBar │ │ │ ├── StatusBarLegend.cs │ │ │ ├── StatusBarLegendGeneric.xaml │ │ │ ├── TaskVisualizer.cs │ │ │ └── TaskVisualizerGeneric.xaml │ │ └── TitleBar │ │ │ ├── SigmaAboutBox.cs │ │ │ └── SigmaAboutBoxGeneric.xaml │ ├── Factories │ │ ├── Defaults │ │ │ ├── AboutFactory.cs │ │ │ ├── DefaultSigmaNotifyIconFactory.cs │ │ │ ├── LoadingIndicatorFactory.cs │ │ │ ├── RootPanelFactory.cs │ │ │ ├── SigmaNotifyIconFactory.cs │ │ │ ├── StatusBar │ │ │ │ ├── StatusBarFactory.cs │ │ │ │ ├── StatusBarLegendFactory.cs │ │ │ │ └── TaskVisualizerFactory.cs │ │ │ ├── TabControlFactory.cs │ │ │ └── TitleBarFactory.cs │ │ └── UIFactory.cs │ ├── Parameterisation │ │ ├── Defaults │ │ │ ├── SigmaCheckBox.xaml │ │ │ ├── SigmaCheckBox.xaml.cs │ │ │ ├── SigmaComboBox.xaml │ │ │ ├── SigmaComboBox.xaml.cs │ │ │ ├── SigmaDynamicGenericBox.cs │ │ │ ├── SigmaGenericBox.cs │ │ │ ├── SigmaSlider.xaml │ │ │ ├── SigmaSlider.xaml.cs │ │ │ ├── SigmaTextBlock.xaml │ │ │ ├── SigmaTextBlock.xaml.cs │ │ │ ├── SigmaTextBox.xaml │ │ │ ├── SigmaTextBox.xaml.cs │ │ │ └── SigmaTimeBlock.cs │ │ ├── ParameterLabel.cs │ │ ├── ParameterView.xaml │ │ ├── ParameterView.xaml.cs │ │ ├── ParameterVisualiserAttribute.cs │ │ ├── ParameterVisualiserInfo.cs │ │ └── UserControlParameterVisualiser.cs │ ├── UIWrapper.cs │ └── Windows │ │ ├── SigmaWindow.cs │ │ └── WPFWindow.cs ├── ViewModel │ ├── Parameterisation │ │ ├── IParameterLabel.cs │ │ ├── IParameterVisualiser.cs │ │ ├── IParameterVisualiserInfo.cs │ │ ├── IParameterVisualiserManager.cs │ │ ├── ParameterVisualiserManager.cs │ │ └── PollParameterHook.cs │ ├── StatusBar │ │ ├── IWPFTaskVisualizationManager.cs │ │ └── TaskVisualizationManager.cs │ ├── Tabs │ │ ├── TabControlUI.cs │ │ └── TabUI.cs │ └── TitleBar │ │ ├── TitleBarControl.cs │ │ └── TitleBarItem.cs ├── WPFController.cs ├── WPFMonitor.cs ├── build │ └── Sigma.Core.Monitors.WPF.template.targets └── packages.config ├── Sigma.Core ├── Architecture │ ├── INetwork.cs │ ├── INetworkArchitecture.cs │ ├── InvalidNetworkArchitectureException.cs │ ├── LayerConstruct.cs │ ├── Linear │ │ ├── LinearNetworkArchitecture.cs │ │ └── Parallel.cs │ └── Network.cs ├── Data │ ├── DataBuffer.cs │ ├── DataType.cs │ ├── Datasets │ │ ├── DatasetBlockwiseSlice.cs │ │ ├── DatasetRecordwiseSlice.cs │ │ ├── ExtractedDataset.cs │ │ ├── IDataset.cs │ │ └── RawDataset.cs │ ├── Extractors │ │ ├── ArrayRecordExtractor.cs │ │ ├── BaseExtractor.cs │ │ ├── CSVRecordExtractor.cs │ │ └── IRecordExtractor.cs │ ├── IDataBuffer.cs │ ├── Iterators │ │ ├── BaseIterator.cs │ │ ├── IDataIterator.cs │ │ ├── MinibatchIterator.cs │ │ ├── UndividedIterator.cs │ │ └── UnifiedIterator.cs │ ├── Preprocessors │ │ ├── Adaptive │ │ │ ├── AdaptiveNormalisingPreprocessor.cs │ │ │ ├── AdaptivePerIndexNormalisingPreprocessor.cs │ │ │ └── BaseAdaptivePreprocessor.cs │ │ ├── BasePreprocessor.cs │ │ ├── IRecordPreprocessor.cs │ │ ├── NormalisingPreprocessor.cs │ │ ├── OneHotPreprocessor.cs │ │ ├── PerIndexNormalisingPreprocessor.cs │ │ ├── PermutePreprocessor.cs │ │ └── ShufflePreprocessor.cs │ ├── Readers │ │ ├── ByteRecordReader.cs │ │ ├── CSVRecordReader.cs │ │ ├── CharacterRecordReader.cs │ │ └── IRecordReader.cs │ └── Sources │ │ ├── CompressedSource.cs │ │ ├── FileSource.cs │ │ ├── IDataSource.cs │ │ ├── MultiSource.cs │ │ ├── URLSource.cs │ │ └── Unpackers.cs ├── Dependencies │ └── DiffSharp.dll ├── Handlers │ ├── ActivationManager.cs │ ├── Backends │ │ ├── Debugging │ │ │ ├── DebugHandler.cs │ │ │ └── DebugReportException.cs │ │ ├── IBlasBackend.cs │ │ ├── ILapackBackend.cs │ │ └── SigmaDiff │ │ │ ├── DiffSharpBackendHandle.cs │ │ │ ├── DiffSharpFloat32BackendHandle.cs │ │ │ ├── DiffSharpFloat32Handler.cs │ │ │ ├── NativeCpu │ │ │ ├── CpuFloat32Handler.cs │ │ │ ├── OpenBlasBlasBackend.cs │ │ │ └── OpenBlasLapackBackend.cs │ │ │ ├── NativeGpu │ │ │ ├── CudaFloat32BackendHandle.cs │ │ │ ├── CudaFloat32Handler.cs │ │ │ └── CudaSigmaDiffDataBuffer.cs │ │ │ ├── PlatformDependentUtils.cs │ │ │ ├── SigmaDiffDataBuffer.cs │ │ │ └── SigmaDiffSharpBackendProvider.cs │ └── IComputationHandler.cs ├── Layers │ ├── BaseLayer.cs │ ├── Cost │ │ ├── BaseCostLayer.cs │ │ ├── SoftMaxCrossEntropyCostLayer.cs │ │ └── SquaredDifferenceCostLayer.cs │ ├── External │ │ ├── InputLayer.cs │ │ └── OutputLayer.cs │ ├── Feedforward │ │ ├── ElementwiseLayer.cs │ │ └── FullyConnectedLayer.cs │ ├── ILayer.cs │ ├── ILayerBuffer.cs │ ├── InternalLayerBuffer.cs │ ├── Recurrent │ │ └── RecurrentLayer.cs │ └── Regularisation │ │ └── DropoutLayer.cs ├── MathAbstract │ ├── Backends │ │ └── SigmaDiff │ │ │ ├── ADNDArray.cs │ │ │ ├── ADNumber.cs │ │ │ ├── ArrayPool.cs │ │ │ ├── NativeCpu │ │ │ ├── ADFloat32NDArray.cs │ │ │ ├── ADFloat32Number.cs │ │ │ └── ADNDFloat32Array.cs │ │ │ └── NativeGpu │ │ │ ├── CudaFloat32NDArray.cs │ │ │ └── CudaFloat32Number.cs │ ├── INDArray.cs │ ├── INumber.cs │ ├── ITraceable.cs │ └── NDArrayUtils.cs ├── Monitors │ ├── ConsoleTaskListMonitor.cs │ ├── HttpMonitor.cs │ ├── IMonitor.cs │ ├── MonitorAdapter.cs │ └── Synchronisation │ │ ├── ISynchronisationHandler.cs │ │ ├── ISynchronisationSource.cs │ │ ├── SetValueCommand.cs │ │ └── SynchronisationHandler.cs ├── Parameterisation │ ├── IParameterType.cs │ ├── IParameterisationManager.cs │ ├── ParameterisationManager.cs │ └── Types │ │ └── RangedParameterType.cs ├── Persistence │ ├── ISerialisationNotifier.cs │ ├── Selectors │ │ ├── IEnvironmentSelector.cs │ │ ├── INetworkSelector.cs │ │ ├── IOperatorSelector.cs │ │ ├── ISelector.cs │ │ ├── ITrainerSelector.cs │ │ ├── Network │ │ │ ├── BaseNetworkSelector.cs │ │ │ └── DefaultNetworkSelector.cs │ │ ├── Operator │ │ │ ├── BaseOperatorSelector.cs │ │ │ ├── CpuMultithreadedOperatorSelector.cs │ │ │ └── CpuSinglethreadedOperator.cs │ │ └── Trainer │ │ │ ├── BaseTrainerSelector.cs │ │ │ └── DefaultTrainerSelector.cs │ ├── Serialisation.cs │ ├── SerialisationTarget.cs │ └── Serialiser.cs ├── Properties │ └── AssemblyInfo.cs ├── Sigma.Core.csproj ├── Sigma.Core.licenseheader ├── Sigma.Core.nuspec ├── Sigma.cs ├── Training │ ├── Hooks │ │ ├── BaseHook.cs │ │ ├── HookInvokeCriteria.cs │ │ ├── IHook.cs │ │ ├── IllegalHookDependencyException.cs │ │ ├── LambdaHook.cs │ │ ├── Modifiers │ │ │ └── ApplyModifierHook.cs │ │ ├── PassNetworkHook.cs │ │ ├── Processors │ │ │ ├── MetricProcessorHook.cs │ │ │ ├── NumberAccumulatorHook.cs │ │ │ ├── RunningTimeProcessorHook.cs │ │ │ ├── TargetMaximisationHook.cs │ │ │ └── TimeSeriesGeneratorHook.cs │ │ ├── Reporters │ │ │ ├── AccumulatedValueReporter.cs │ │ │ ├── CurrentEpochIterationReporter.cs │ │ │ ├── MultiClassificationAccuracyReporter.cs │ │ │ ├── RunningTimeReporter.cs │ │ │ ├── TargetMaximisationReporter.cs │ │ │ ├── UniClassificationAccuracyReporter.cs │ │ │ ├── ValueReporter.cs │ │ │ └── ValueSourceReporter.cs │ │ ├── Saviors │ │ │ └── DiskSaviorHook.cs │ │ ├── Scorers │ │ │ ├── BaseAccuracyScorer.cs │ │ │ ├── MultiClassificationAccuracyScorer.cs │ │ │ └── UniClassificationAccuracyScorer.cs │ │ ├── Stoppers │ │ │ └── StopTrainingHook.cs │ │ └── TargetMode.cs │ ├── ITrainer.cs │ ├── Initialisers │ │ ├── BaseInitialiser.cs │ │ ├── ConstantValueInitialiser.cs │ │ ├── CustomInitialiser.cs │ │ ├── GaussianInitialiser.cs │ │ ├── IInitialiser.cs │ │ └── XavierInitialiser.cs │ ├── Mergers │ │ ├── AverageNetworkMerger.cs │ │ ├── BaseNetworkMerger.cs │ │ ├── INetworkMerger.cs │ │ ├── MaxNetworkMerger.cs │ │ ├── MultiNetworkMerger.cs │ │ └── WeightedNetworkMerger.cs │ ├── Modifiers │ │ ├── BaseValueModifier.cs │ │ ├── ClipValueModifier.cs │ │ ├── IValueModifier.cs │ │ └── ScaleValueModifier.cs │ ├── Operators │ │ ├── Backends │ │ │ ├── NativeCpu │ │ │ │ ├── CpuMultithreadedOperator.cs │ │ │ │ └── Workers │ │ │ │ │ └── CpuWorker.cs │ │ │ └── NativeGpu │ │ │ │ ├── CudaSinglethreadedOperator.cs │ │ │ │ └── Workers │ │ │ │ └── CudaWorker.cs │ │ ├── BaseOperator.cs │ │ ├── ExecutionState.cs │ │ ├── IOperator.cs │ │ └── Workers │ │ │ ├── BaseWorker.cs │ │ │ └── IWorker.cs │ ├── Optimisers │ │ ├── Gradient │ │ │ ├── BaseGradientOptimiser.cs │ │ │ ├── GradientDescentOptimiser.cs │ │ │ └── Memory │ │ │ │ ├── AdadeltaOptimiser.cs │ │ │ │ ├── AdagradOptimiser.cs │ │ │ │ ├── BaseArrayMemoryGradientOptimiser.cs │ │ │ │ ├── BaseMemoryGradientOptimiser.cs │ │ │ │ └── MomentumGradientOptimiser.cs │ │ └── IOptimiser.cs │ ├── Providers │ │ ├── DefaultDataProvider.cs │ │ └── IDataProvider.cs │ └── Trainer.cs ├── Utils │ ├── ArrayUtils.cs │ ├── DataUtils.cs │ ├── Defaults.cs │ ├── DictionaryUtils.cs │ ├── DiskCacheProvider.cs │ ├── HookUtils.cs │ ├── ICacheProvider.cs │ ├── IDeepCopyable.cs │ ├── IEnumerableExtensions.cs │ ├── IRegistry.cs │ ├── IRegistryResolver.cs │ ├── ITaskManager.cs │ ├── ITaskObserver.cs │ ├── LoggingUtils.cs │ ├── Namers.cs │ ├── PrintUtils.cs │ ├── ProcessUtils.cs │ ├── Registry.cs │ ├── RegistryResolver.cs │ ├── RegistryUtils.cs │ ├── SigmaException.cs │ ├── SystemInformationUtils.cs │ ├── ThreadUtils.cs │ ├── TimeStep.cs │ ├── TimeUnit.cs │ ├── WeakList.cs │ └── WebUtils.cs ├── app.config ├── build │ └── Sigma.Core.targets ├── libgcc_s_seh-1.dll ├── libgfortran-3.dll ├── libopenblas.dll ├── libopenblas.so ├── libquadmath-0.dll ├── packages.config └── sigmakernels.ptx ├── Sigma.Kernels ├── Sigma.Kernels.licenseheader ├── Sigma.Kernels.vcxproj └── sigmakernels.cu ├── Sigma.Samples ├── .gitignore ├── 01-IRIS │ ├── 02-IRIS.csproj │ ├── App.config │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── Entypo-license.txt │ │ ├── Entypo.ttf │ │ ├── Icons.xaml │ │ ├── IconsNonShared.xaml │ │ └── WindowsIcons-license.txt │ └── packages.config ├── 01-MNIST │ ├── 01-MNIST.csproj │ ├── App.config │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── Entypo-license.txt │ │ ├── Entypo.ttf │ │ ├── Icons.xaml │ │ ├── IconsNonShared.xaml │ │ └── WindowsIcons-license.txt │ └── packages.config └── Sigma.Samples.sln ├── Sigma.Tests.Internals.Backend ├── App.config ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Sigma.Tests.Internals.Backend.csproj └── packages.config ├── Sigma.Tests.Internals.WPF ├── App.config ├── EmptyPanel.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Resources │ ├── Entypo-license.txt │ ├── Entypo.ttf │ ├── Icons.xaml │ ├── IconsNonShared.xaml │ └── WindowsIcons-license.txt ├── Sigma.Tests.Internals.WPF.csproj ├── TestPanel.cs └── packages.config ├── Sigma.Tests ├── BaseLocaleTest.cs ├── Data │ ├── Datasets │ │ ├── TestDatasetBlockwiseSlice.cs │ │ ├── TestDatasetRecordwiseSlice.cs │ │ └── TestExtractedDataset.cs │ ├── Extractors │ │ ├── TestArrayRecordExtractor.cs │ │ └── TestCSVRecordExtractor.cs │ ├── Iterators │ │ ├── TestMinibatchIterator.cs │ │ ├── TestUndividedIterator.cs │ │ └── TestUnifiedIterator.cs │ ├── Preprocessors │ │ ├── TestNormalisingPreprocessor.cs │ │ └── TestOneHotPreprocessor.cs │ ├── Readers │ │ ├── TestByteRecordExtractor.cs │ │ └── TestCSVRecordReader.cs │ ├── Sources │ │ ├── TestFileSource.cs │ │ ├── TestMultiSource.cs │ │ └── TestURLSource.cs │ └── TestDataBuffer.cs ├── Layers │ └── MockLayer.cs ├── Math │ ├── TestNDArray.cs │ └── TestNumber.cs ├── Properties │ └── AssemblyInfo.cs ├── Sigma.Tests.csproj ├── Sigma.Tests.licenseheader ├── TestCUDAInstallation.cs ├── TestSigmaEnvironment.cs ├── Training │ ├── Initialisers │ │ ├── TestConstantValueInitialiser.cs │ │ ├── TestCustomInitialiser.cs │ │ └── TestGaussianInitialiser.cs │ ├── Mergers │ │ ├── NetworkMergerTestUtils.cs │ │ ├── TestAverageNetworkMerger.cs │ │ └── TestWeightedNetworkMerger.cs │ ├── MockTrainer.cs │ └── Operators │ │ └── Backend │ │ └── NativeCpu │ │ ├── TestCpuMultithreadedOperator.cs │ │ └── Workers │ │ └── TestCpuWorker.cs ├── Utils │ ├── TestArrayUtils.cs │ ├── TestDiskCacheProvider.cs │ ├── TestRegistry.cs │ ├── TestRegistryResolver.cs │ ├── TestTaskManager.cs │ └── TestTaskObserver.cs ├── app.config └── packages.config ├── Sigma.sln ├── Sigma.sln.DotSettings └── build.bat /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | dist: precise 3 | solution: Sigma.sln 4 | install: 5 | - nuget restore Sigma.sln 6 | - nuget install NUnit.Runners -Version 3.5.0 -OutputDirectory testrunner 7 | script: 8 | - xbuild /p:Configuration=TravisBuild Sigma.sln 9 | - mono ./testrunner/NUnit.ConsoleRunner.3.5.0/tools/nunit3-console.exe ./Sigma.Tests/bin/x64/TravisBuild/Sigma.Tests.dll 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Florian Cäsar, Michael Plainer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | LiveCharts.Geared 24 | LiveCharts.Geared drastically enhances the performance of charts and is free 25 | for open source projects. As long as the code written with Geared is not edited 26 | by the user (therefore the user is not a developer), he / she or the company / 27 | organization does not have to acquire a LiveCharts.Geared license in order to 28 | use Sigma. -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | # Sigma Roadmap 2 | 3 | The never ending list of nice-to-have things by project. These lists are not meant to be taken entirely seriously. Though they would be nice to have. 4 | 5 | ## Sigma.Core 6 | 7 | * Automated hyperparameter search across trainers 8 | * "Supervisor" to automagically and easily manipulate certain parameters (with smart guesses) 9 | * Multiple search modes for supervisor (e.g. basic grid search, advanced hyperparameter optimisation) 10 | * Truly distributed operator across devices 11 | * Operates on sub-operators for each device 12 | * Plugin / layer dependency management 13 | * Automically load and inject custom layers 14 | * Custom code can be stored within the environment / trainer files 15 | * Improved preprocessor pipeline with extra step before extraction 16 | * Use extra step to detect values for preprocessing (e.g. for auto-normalisation) 17 | * Network training 18 | * Implement a trainer that can be controlled via a custom network protocol and functions as a wrapper for all trainers 19 | 20 | ## Sigma.Core.Monitors General 21 | 22 | * TCP monitor 23 | * Allow TCP connections to receive and send hooks (just like any monitor) 24 | * Remote monitoring and interaction from other devices 25 | * HTTP monitor 26 | * On top of TCP monitor 27 | * As a website (maybe webhost) to easily remotely monitor and do fancy stuff 28 | * Android / iOS monitor 29 | * On top of HTTP / TCP monitor 30 | * Monitor only (no learning on phone) 31 | * Learning (visualisation) on phone 32 | * [Smonity](https://smonity.github.io/) monitor (SMonitor) 33 | * Monitor RAM 34 | * Receive notifications 35 | 36 | ## Sigma.Core.Monitors.WPF 37 | 38 | * Language change within the GUI without having to restart _everything_ 39 | * Drastically improved chart performance 40 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Reflection; 10 | using System.Runtime.InteropServices; 11 | 12 | // General Information about an assembly is controlled through the following 13 | // set of attributes. Change these attribute values to modify the information 14 | // associated with an assembly. 15 | [assembly: AssemblyTitle("Sigma.Core.Monitors.WPF.Tests")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyConfiguration("")] 18 | [assembly: AssemblyCompany("")] 19 | [assembly: AssemblyProduct("Sigma.Core.Monitors.WPF.Tests")] 20 | [assembly: AssemblyCopyright("Copyright © 2016")] 21 | [assembly: AssemblyTrademark("")] 22 | [assembly: AssemblyCulture("")] 23 | 24 | // Setting ComVisible to false makes the types in this assembly not visible 25 | // to COM components. If you need to access a type in this assembly from 26 | // COM, set the ComVisible attribute to true on that type. 27 | [assembly: ComVisible(false)] 28 | 29 | // The following GUID is for the ID of the typelib if this project is exposed to COM 30 | [assembly: Guid("b3e3b0be-2f6e-4e29-bac2-10ba6ec4dea6")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] 44 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF.Tests/Resources/Entypo-license.txt: -------------------------------------------------------------------------------- 1 | Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license. 2 | 3 | http://creativecommons.org/licenses/by-sa/3.0/ -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF.Tests/Resources/Entypo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF.Tests/Resources/Entypo.ttf -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF.Tests/View/TestUIWrapper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Threading; 10 | using System.Windows.Controls; 11 | using NUnit.Framework; 12 | using Sigma.Core.Monitors.WPF.View; 13 | // ReSharper disable InconsistentNaming 14 | 15 | namespace Sigma.Core.Monitors.WPF.Tests.View 16 | { 17 | public class TestUIWrapper 18 | { 19 | [TestCase] 20 | public void TestUIWrapperCreation() 21 | { 22 | Thread fred = new Thread(() => 23 | { 24 | TestUIWrapperClass wrapper = new TestUIWrapperClass(); 25 | 26 | Assert.IsTrue(wrapper.WrappedContent != null); 27 | 28 | wrapper.WrappedContent.Test = "hello"; 29 | 30 | Assert.AreEqual(wrapper.WrappedContent.Test, "hello"); 31 | 32 | wrapper.WrappedContent = new TestControl() { Test = "world" }; 33 | 34 | Assert.AreNotEqual(wrapper.WrappedContent.Test, "hello"); 35 | Assert.AreEqual(wrapper.WrappedContent.Test, "world"); 36 | }); 37 | 38 | fred.SetApartmentState(ApartmentState.STA); 39 | fred.Priority = ThreadPriority.Highest; 40 | fred.Start(); 41 | 42 | fred.Join(); 43 | } 44 | 45 | private class TestControl : ContentControl 46 | { 47 | public string Test { get; set; } 48 | } 49 | 50 | private class TestUIWrapperClass : UIWrapper 51 | { 52 | 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF.Tests/WPFMonitorTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Threading; 10 | using NUnit.Framework; 11 | // ReSharper disable InconsistentNaming 12 | 13 | namespace Sigma.Core.Monitors.WPF.Tests 14 | { 15 | public class WPFMonitorTest 16 | { 17 | private static SigmaEnvironment ClearAndCreate(string identifier) 18 | { 19 | SigmaEnvironment.Clear(); 20 | 21 | return SigmaEnvironment.Create(identifier); 22 | } 23 | 24 | [TestCase] 25 | public void TestWPFMonitorCreation() 26 | { 27 | SigmaEnvironment sigma = ClearAndCreate("Test"); 28 | 29 | WPFMonitor monitor = sigma.AddMonitor(new WPFMonitor("Sigma GUI Demo")); 30 | monitor.Priority = ThreadPriority.Lowest; 31 | 32 | Assert.AreSame(sigma, monitor.Sigma); 33 | Assert.AreEqual(monitor.Priority, ThreadPriority.Lowest); 34 | Assert.AreEqual(monitor.Title, "Sigma GUI Demo"); 35 | Assert.AreNotEqual(monitor.Title, "Sigma GUI Demo2"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/App.xaml.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Windows; 10 | 11 | namespace Sigma.Core.Monitors.WPF 12 | { 13 | /// 14 | /// This file contains the general interaction logic for App.xaml. 15 | /// See App.xaml for why these files are required. 16 | /// 17 | // ReSharper disable once RedundantExtendsListEntry 18 | public partial class App : Application 19 | { 20 | /// 21 | /// The corresponding WPF monitor. 22 | /// 23 | protected WPFMonitor Monitor; 24 | 25 | // ReSharper disable once RedundantBaseConstructorCall 26 | public App(WPFMonitor monitor) : base() 27 | { 28 | Monitor = monitor; 29 | 30 | InitializeComponent(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Model/SigmaGrid/GridExtensions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Windows; 12 | using System.Windows.Controls; 13 | 14 | namespace Sigma.Core.Monitors.WPF.Model.SigmaGrid 15 | { 16 | /// 17 | /// A static class that provides functionality to the class. 18 | /// 19 | public static class GridExtensions 20 | { 21 | // ReSharper disable once InconsistentNaming 22 | /// 23 | /// Get a at a specific point ont the grid. 24 | /// If multiple items have been added to the same position or some are overlapping (e.g. column span etc.) 25 | /// all are returned. 26 | /// 27 | /// The grid itself. 28 | /// The row to get a specific item. 29 | /// The column to get a specific item. 30 | /// A that contains all elements that are inside that grid. 31 | public static IEnumerable GetChildAt(this Grid instance, int row, int column) 32 | { 33 | if (null == instance) 34 | { 35 | throw new ArgumentNullException(nameof(instance)); 36 | } 37 | 38 | List list = new List(); 39 | foreach (FrameworkElement fe in instance.Children) 40 | { 41 | int rowStart = Grid.GetRow(fe); 42 | int rowEnd = rowStart + Grid.GetRowSpan(fe) - 1; 43 | int columnStart = Grid.GetColumn(fe); 44 | int columnEnd = columnStart + Grid.GetColumnSpan(fe) - 1; 45 | 46 | if (row >= rowStart && row <= rowEnd && column >= columnStart && column <= columnEnd) 47 | { 48 | list.Add(fe); 49 | } 50 | } 51 | 52 | return list; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Model/UI/Resources/FontResource.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 112 6 | 56 7 | 45 8 | 34 9 | 24 10 | 20 11 | 12 | 15 13 | 13 14 | 12 15 | 16 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/Charts/CartesianChartPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using LiveCharts; 10 | using LiveCharts.Wpf; 11 | 12 | namespace Sigma.Core.Monitors.WPF.Panels.Charts 13 | { 14 | public class CartesianChartPanel : ChartPanel, double> 15 | { 16 | /// 17 | /// Create a ChartPanel with a given title. 18 | /// If a title is not sufficient modify . 19 | /// 20 | /// The given tile. 21 | /// The content for the header. If null is passed, 22 | /// the title will be used. 23 | public CartesianChartPanel(string title, object headerContent = null) : base(title, headerContent) { } 24 | } 25 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/Charts/Definitions/IPointVisualiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Collections.Generic; 10 | 11 | namespace Sigma.Core.Monitors.WPF.Panels.Charts.Definitions 12 | { 13 | public interface IPointVisualiser 14 | { 15 | void Add(object value); 16 | void AddRange(IEnumerable values); 17 | } 18 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/Charts/LineChartPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Windows; 12 | using System.Windows.Media; 13 | using LiveCharts; 14 | using LiveCharts.Wpf; 15 | using Sigma.Core.Monitors.WPF.Panels.Charts.Definitions; 16 | 17 | namespace Sigma.Core.Monitors.WPF.Panels.Charts 18 | { 19 | public class LineChartPanel : GenericPanel 20 | { 21 | protected readonly StepLineSeries StepLine; 22 | 23 | public LineChartPanel(string title, object headerContent = null) : base(title, headerContent) 24 | { 25 | Content = new CartesianChart { Zoom = ZoomingOptions.Xy }; 26 | 27 | 28 | StepLine = new StepLineSeries 29 | { 30 | Values = new ChartValues() 31 | }; 32 | 33 | // TODO: set the AnimationSpeed in style 34 | Content.AnimationsSpeed = TimeSpan.FromMilliseconds(100); 35 | 36 | //Content.SetDrawMarginWidth(Content.GetDrawMarginElements() * 0.9); 37 | 38 | Content.Series.Add(StepLine); 39 | 40 | //Content.VisualElements.Chart.AxisX[0].MinValue = 10; 41 | 42 | ContentGrid.Margin = new Thickness(5); 43 | } 44 | 45 | /// 46 | /// Add a give value to the LineChart and update the view. 47 | /// 48 | /// The value that will be added. 49 | public virtual void Add(double value) 50 | { 51 | StepLine.Values.Add(value); 52 | 53 | } 54 | 55 | /// 56 | /// Add a range of given values to the LineChart and update the view once. 57 | /// 58 | /// The range of values that will be added. 59 | //public virtual void AddRange(IEnumerable values) 60 | //{ 61 | // StepLine.Values.AddRange(values); 62 | // //TODO: update 63 | //} 64 | } 65 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/Controls/RectanglePanel.cs: -------------------------------------------------------------------------------- 1 | namespace Sigma.Core.Monitors.WPF.Panels.Controls 2 | { 3 | public class RectanglePanel : GenericPanel 4 | { 5 | /// 6 | /// Create a SigmaPanel with a given title. 7 | /// If a title is not sufficient modify . 8 | /// 9 | /// The given tile. 10 | /// The content for the header. If null is passed, 11 | /// the title will be used. 12 | public RectanglePanel(string title, int width, int height, int size, object headerContent = null) : base(title, headerContent) 13 | { 14 | Content = new RectangleCanvas 15 | { 16 | GridHeight = height, 17 | GridWidth = width, 18 | PointSize = size, 19 | }; 20 | 21 | Content.UpdateRects(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/DataGrids/CustomDataGridPanel.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Panels/DataGrids/CustomDataGridPanel.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/DataGrids/SigmaDataGridPanel.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Panels/DataGrids/SigmaDataGridPanel.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/DataGrids/SimpleDataGridPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Collections.ObjectModel; 10 | 11 | namespace Sigma.Core.Monitors.WPF.Panels.DataGrids 12 | { 13 | public class SimpleDataGridPanel : SigmaDataGridPanel 14 | { 15 | public ObservableCollection Items { get; } 16 | 17 | public SimpleDataGridPanel(string title, object content = null) : base(title, content) 18 | { 19 | Items = new ObservableCollection(); 20 | 21 | Content.ItemsSource = Items; 22 | } 23 | 24 | } 25 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/IInputPanel.cs: -------------------------------------------------------------------------------- 1 | using Sigma.Core.MathAbstract; 2 | 3 | namespace Sigma.Core.Monitors.WPF.Panels 4 | { 5 | public interface IInputPanel 6 | { 7 | bool IsReady { get; } 8 | INDArray Values { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/IOutputPanel.cs: -------------------------------------------------------------------------------- 1 | using Sigma.Core.MathAbstract; 2 | 3 | namespace Sigma.Core.Monitors.WPF.Panels 4 | { 5 | public interface IOutputPanel 6 | { 7 | IInputPanel Input { get; set; } 8 | //TODO: think about beatiful system 9 | void SetInputReference(INDArray values); 10 | } 11 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/Logging/LogTextPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Windows; 11 | using System.Windows.Controls; 12 | using log4net; 13 | using log4net.Appender; 14 | using log4net.Core; 15 | using log4net.Repository.Hierarchy; 16 | 17 | namespace Sigma.Core.Monitors.WPF.Panels.Logging 18 | { 19 | /// 20 | /// This pastes all new log entries in a . 21 | /// 22 | /// For a more sophisticated logger see . 23 | /// 24 | public class LogTextPanel : GenericPanel, IAppender 25 | { 26 | /// 27 | /// A panel that displays log entries in a . It will automatically assign 28 | /// to the appender list (i.e. receive logs). 29 | /// 30 | /// 31 | /// 32 | public LogTextPanel(string title, object content = null) : base(title, content) 33 | { 34 | Content = new TextBox 35 | { 36 | IsReadOnly = true, 37 | TextWrapping = TextWrapping.Wrap, 38 | AcceptsReturn = true, 39 | Margin = new Thickness(10) 40 | }; 41 | 42 | ((Hierarchy) LogManager.GetRepository()).Root.AddAppender(this); 43 | } 44 | 45 | void IAppender.Close() 46 | { 47 | } 48 | 49 | void IAppender.DoAppend(LoggingEvent loggingEvent) 50 | { 51 | try 52 | { 53 | 54 | Dispatcher.Invoke(() => Content.AppendText($"{loggingEvent.Level.Name}\t{loggingEvent.MessageObject}\n")); 55 | } 56 | catch (Exception) 57 | { 58 | ((IAppender) this).Close(); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/Parameterisation/ParameterPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Windows; 11 | using Sigma.Core.Monitors.Synchronisation; 12 | using Sigma.Core.Monitors.WPF.View.Parameterisation; 13 | using Sigma.Core.Monitors.WPF.View.Windows; 14 | using Sigma.Core.Monitors.WPF.ViewModel.Parameterisation; 15 | using Sigma.Core.Utils; 16 | 17 | namespace Sigma.Core.Monitors.WPF.Panels.Parameterisation 18 | { 19 | public class ParameterPanel : GenericPanel 20 | { 21 | /// 22 | /// Create a SigmaPanel with a given title. 23 | /// If a title is not sufficient modify . 24 | /// 25 | /// The given tile. 26 | /// The content for the header. If null is passed, 27 | /// the title will be used. 28 | public ParameterPanel(string title, IParameterVisualiserManager visualiserManager, ISynchronisationHandler synchronisationHandler, object headerContent = null) : base(title, headerContent) 29 | { 30 | Content = new ParameterView(visualiserManager, synchronisationHandler); 31 | Content.Margin = new Thickness(10, 10, 10, 0); 32 | } 33 | public ParameterPanel(string title, SigmaEnvironment environment, SigmaWindow window, object headerContent = null) : this(title, window.ParameterVisualiser, environment.SynchronisationHandler, headerContent) { } 34 | 35 | public void Add(string name, Type type, IRegistry registry, string key) 36 | { 37 | Content.Add(name, type, registry, key); 38 | } 39 | 40 | public void Add(string name, object visualiserAndDisplayer, IRegistry registry, string key) 41 | { 42 | Content.Add(name, visualiserAndDisplayer, registry, key); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/SigmaPanel.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Panels/SigmaPanel.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Panels/XamlPanel.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Sigma.Core.Monitors.WPF.Panels 4 | { 5 | /// 6 | /// A generic panel that works with XAML UI elements (elments with a parameterless cosntructor). 7 | /// It automatically generates passed . 8 | /// 9 | /// The type of the XAML control. 10 | public class XamlPanel : GenericPanel where T: UIElement, new() 11 | { 12 | /// 13 | /// Create a XamlPanel with a given title. 14 | /// If a title is not sufficient modify . 15 | /// 16 | /// The given tile. 17 | /// The content that will be placed inside the panel. 18 | /// The content for the header. If null is passed, 19 | /// the title will be used. 20 | public XamlPanel(string title, T content, object headerContent = null) : base(title, content, headerContent) 21 | { 22 | } 23 | 24 | /// 25 | /// Create a SigmaPanel with a given title. 26 | /// If a title is not sufficient modify . 27 | /// 28 | /// The given tile. 29 | /// The content for the header. If null is passed, 30 | /// the title will be used. 31 | public XamlPanel(string title, object headerContent = null) : base(title, headerContent) 32 | { 33 | Content = new T(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Properties/Resources.de-DE.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Properties/Resources.de-DE.Designer.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Properties/Resources.en-GB.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Properties/Resources.en-GB.Designer.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Properties/Resources.en-US.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Properties/Resources.en-US.Designer.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | //------------------------------------------------------------------------------ 10 | // 11 | // This code was generated by a tool. 12 | // Runtime Version:4.0.30319.42000 13 | // 14 | // Changes to this file may cause incorrect behavior and will be lost if 15 | // the code is regenerated. 16 | // 17 | //------------------------------------------------------------------------------ 18 | 19 | namespace Sigma.Core.Monitors.WPF.Properties 20 | { 21 | 22 | 23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 24 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 25 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 26 | { 27 | 28 | private static Settings defaultInstance = ((Settings) (global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 29 | 30 | public static Settings Default 31 | { 32 | get 33 | { 34 | return defaultInstance; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Resources/Entypo-license.txt: -------------------------------------------------------------------------------- 1 | Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license. 2 | 3 | http://creativecommons.org/licenses/by-sa/3.0/ -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Resources/Entypo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Resources/Entypo.ttf -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Resources/icons/sigma.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Resources/icons/sigma.ico -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Resources/icons/sigma_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Resources/icons/sigma_256x256.png -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Sigma.Core.Monitors.WPF.licenseheader: -------------------------------------------------------------------------------- 1 | extensions: .cs 2 | /* 3 | MIT License 4 | 5 | Copyright (c) 2016-%CurrentYear% Florian Cäsar, Michael Plainer 6 | 7 | For full license see LICENSE in the root directory of this project. 8 | */ 9 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Sigma.Core.Monitors.WPF.targets: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/Sigma.Core.Monitors.WPF.targets -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/CustomControls/DrawCanvasDark.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/CustomControls/DrawCanvasLight.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/DarkStyle.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/LightStyle.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/LiveCharts/AxisDark.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 8 | 9 | 27 | 28 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/Panels/DataGrid.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/SigmaGrid/CardColoursDark.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/SigmaGrid/CardColoursLight.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/SigmaGrid/CardStyle.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/SigmaStatusBar/StatusBarLegendStyle.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/SigmaStatusBar/TaskVisualizerStyle.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 12 | 13 | 19 | 20 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/SigmaStyles.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/TitleBar/MenuStyle.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 35 | 36 | 7 | 8 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/TitleBar/MenuStyleLight.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/TitleBar/SigmaAboutBoxStyle.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 12 | 13 | --> 7 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Themes/Styles/Window/DialogHostStyle.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 8 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Utils/AttributeUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | using System.Reflection; 13 | 14 | namespace Sigma.Core.Monitors.WPF.Utils 15 | { 16 | public static class AttributeUtils 17 | { 18 | public static IEnumerable GetTypesWithAttribute(Type attribute) 19 | { 20 | return AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => GetTypesWithAttribute(assembly, attribute)); 21 | } 22 | 23 | public static IEnumerable GetTypesWithAttribute(Assembly assembly, Type attribute) 24 | { 25 | return assembly.GetTypes().Where(type => type.GetCustomAttributes(attribute, true).Length > 0); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Utils/BindUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Data; 3 | 4 | namespace Sigma.Core.Monitors.WPF.Utils 5 | { 6 | public static class BindUtils 7 | { 8 | public static Binding Bind(object source, string sourcePropertyName, DependencyObject sourceObject, DependencyProperty targetProperty, BindingMode mode = BindingMode.Default) 9 | { 10 | Binding binding = new Binding 11 | { 12 | Source = source, 13 | Path = new PropertyPath(sourcePropertyName), 14 | Mode = mode, 15 | UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged 16 | }; 17 | BindingOperations.SetBinding(sourceObject, targetProperty, binding); 18 | 19 | return binding; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Utils/ChartPanelPerformance.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Collections.Generic; 10 | using LiveCharts; 11 | using LiveCharts.Wpf; 12 | using LiveCharts.Wpf.Charts.Base; 13 | using Sigma.Core.Monitors.WPF.Panels.Charts; 14 | 15 | namespace Sigma.Core.Monitors.WPF.Utils 16 | { 17 | /// 18 | /// This extension class, adds abilities to improve the performance of s. 19 | /// 20 | public static class ChartPanelPerformance 21 | { 22 | /// 23 | /// Set all required actions to improve the performance of the . 24 | /// This method allows to disable animations, hovering, and tooltips. It will not reenable them. 25 | /// 26 | public static ChartPanel Fast(this ChartPanel chart, bool animationsEnabled = false, bool hoverEnabled = false, bool pointGemeotryEnabled = false) where TChart : Chart, new() where TSeries : Series, new() where TValues : IList, IChartValues, new() 27 | { 28 | if (!animationsEnabled) 29 | { 30 | chart.Content.DisableAnimations = false; 31 | } 32 | 33 | if (!hoverEnabled) 34 | { 35 | chart.Content.Hoverable = false; 36 | chart.Content.DataTooltip = null; 37 | } 38 | 39 | if (!pointGemeotryEnabled) 40 | { 41 | foreach (TSeries series in chart.Series) 42 | { 43 | series.PointGeometry = null; 44 | } 45 | } 46 | 47 | return chart; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Utils/ChartPanelVisualisation.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using LiveCharts; 3 | using LiveCharts.Wpf; 4 | using LiveCharts.Wpf.Charts.Base; 5 | using Sigma.Core.Monitors.WPF.Panels.Charts; 6 | 7 | namespace Sigma.Core.Monitors.WPF.Utils 8 | { 9 | public static class ChartPanelVisualisation 10 | { 11 | public static ChartPanel SetLineSmoothness(this ChartPanel chart, double lineSmoothness) where TChart : Chart, new() where TSeries : LineSeries, new() where TValues : IList, IChartValues, new() 12 | { 13 | foreach (TSeries series in chart.Series) 14 | { 15 | series.LineSmoothness = lineSmoothness; 16 | } 17 | 18 | return chart; 19 | } 20 | 21 | public static ChartPanel Linearify(this ChartPanel chart) where TChart : Chart, new() where TSeries : LineSeries, new() where TValues : IList, IChartValues, new() 22 | { 23 | return chart.SetLineSmoothness(0); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Utils/Converters/InverseBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Windows.Data; 11 | 12 | namespace Sigma.Core.Monitors.WPF.Utils.Converters 13 | { 14 | /// 15 | /// This converter inverses a given boolean. 16 | /// 17 | /// True will become False and vice versa. 18 | /// 19 | [ValueConversion(typeof(bool), typeof(bool))] 20 | public class InverseBooleanConverter : IValueConverter 21 | { 22 | #region IValueConverter Members 23 | 24 | /// 25 | public object Convert(object value, Type targetType, object parameter, 26 | System.Globalization.CultureInfo culture) 27 | { 28 | if (targetType != typeof(bool)) 29 | throw new InvalidOperationException("The target must be a boolean"); 30 | 31 | return value != null && !(bool)value; 32 | } 33 | 34 | /// 35 | public object ConvertBack(object value, Type targetType, object parameter, 36 | System.Globalization.CultureInfo culture) 37 | { 38 | throw new NotSupportedException(); 39 | } 40 | 41 | #endregion 42 | } 43 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Utils/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Input; 7 | 8 | namespace Sigma.Core.Monitors.WPF.Utils 9 | { 10 | public class RelayCommand : ICommand 11 | { 12 | readonly Action _execute; 13 | readonly Func _canExecute; 14 | 15 | public RelayCommand(Action execute) : this(execute, null) { } 16 | public RelayCommand(Action execute) : this(execute, null) { } 17 | public RelayCommand(Action execute, Func canExecute) 18 | { 19 | if (execute == null) 20 | throw new ArgumentNullException(nameof(execute)); 21 | 22 | _execute = p => execute(); 23 | _canExecute = canExecute; 24 | } 25 | 26 | public RelayCommand(Action execute, Func canExecute) 27 | { 28 | if (execute == null) throw new ArgumentNullException(nameof(execute)); 29 | 30 | _execute = execute; 31 | _canExecute = canExecute; 32 | } 33 | 34 | public bool CanExecute(object parameter) 35 | { 36 | return _canExecute?.Invoke() ?? true; 37 | } 38 | 39 | public event EventHandler CanExecuteChanged 40 | { 41 | add { CommandManager.RequerySuggested += value; } 42 | remove { CommandManager.RequerySuggested -= value; } 43 | } 44 | 45 | public void Execute(object parameter) 46 | { 47 | _execute(parameter); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/Utils/WindowUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Threading; 11 | using System.Windows; 12 | using System.Windows.Threading; 13 | 14 | namespace Sigma.Core.Monitors.WPF.Utils 15 | { 16 | public static class WindowUtils 17 | { 18 | /// 19 | /// This methods dispatches a given command in the thread of the window. 20 | /// If its already the correct thread, it will be executed in the current one. 21 | /// 22 | /// The window the action will be performed on. 23 | /// The command that will be executed. 24 | public static void DispatchCommand(this Window window, Action command) 25 | { 26 | if (command == null) 27 | { 28 | throw new ArgumentNullException(nameof(command)); 29 | } 30 | 31 | if (Dispatcher.CurrentDispatcher.Thread == Thread.CurrentThread) 32 | { 33 | command(); 34 | } 35 | else 36 | { 37 | window.Dispatcher.Invoke(command); 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Colours/IColourManager.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Windows; 10 | using MaterialDesignColors; 11 | 12 | namespace Sigma.Core.Monitors.WPF.View.Colours 13 | { 14 | /// 15 | /// A allows to change the look and feel of the application. 16 | /// 17 | public interface IColourManager 18 | { 19 | /// 20 | /// The application environment. 21 | /// 22 | Application App { get; set; } 23 | 24 | /// 25 | /// A reference to the root window this ColourManager belongs to. 26 | /// 27 | Window Window { get; set; } 28 | 29 | /// 30 | /// The primary colour of the app. Get via . 31 | /// 32 | Swatch PrimaryColor { get; set; } 33 | 34 | /// 35 | /// The secondary colour of the app. Get via . 36 | /// 37 | Swatch SecondaryColor { get; set; } 38 | 39 | /// 40 | /// Switch between light and dark theme. 41 | /// 42 | bool Dark { get; set; } 43 | 44 | /// 45 | /// Switch between default and alternate style. 46 | /// 47 | bool Alternate { get; set; } 48 | 49 | /// 50 | /// Force an update of all values. Normally not required. 51 | /// 52 | void ForceUpdate(); 53 | } 54 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/CustomControls/Panels/Control/SigmaPlaybackControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Sigma.Core.Monitors.WPF.View.CustomControls.Panels.Control 2 | { 3 | partial class SigmaControlPlayback 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | components = new System.ComponentModel.Container(); 32 | } 33 | 34 | #endregion 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/CustomControls/Panels/TicTacToe/TicTacToeButtonGeneric.xaml: -------------------------------------------------------------------------------- 1 |  4 | 26 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/CustomControls/StatusBar/StatusBarLegendGeneric.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 36 | 37 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/CustomControls/StatusBar/TaskVisualizer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/View/CustomControls/StatusBar/TaskVisualizer.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Factories/Defaults/AboutFactory.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Windows; 10 | using MaterialDesignThemes.Wpf; 11 | using Sigma.Core.Monitors.WPF.View.CustomControls.TitleBar; 12 | using Sigma.Core.Monitors.WPF.View.Windows; 13 | 14 | namespace Sigma.Core.Monitors.WPF.View.Factories.Defaults 15 | { 16 | /// 17 | /// This creates a with specified text and . 18 | /// 19 | /// The style will be applied from the file: SigmaAboutBoxStyle.xaml 20 | /// 21 | public class AboutFactory : IUIFactory 22 | { 23 | /// 24 | /// The that will be used (e.g. to close it again). 25 | /// 26 | private readonly DialogHost _windowDialogHost; 27 | 28 | /// 29 | /// Create a new with the from . 30 | /// 31 | /// The , the will produce in. 32 | public AboutFactory(SigmaWindow window) : this(window.DialogHost) { } 33 | 34 | /// 35 | /// Create a new with a given . 36 | /// 37 | /// The , that will be passed to the box. 38 | public AboutFactory(DialogHost windowDialogHost) 39 | { 40 | _windowDialogHost = windowDialogHost; 41 | } 42 | 43 | public UIElement CreateElement(Application app, Window window, params object[] parameters) 44 | { 45 | return new SigmaAboutBox 46 | { 47 | DialogHost = _windowDialogHost, 48 | Heading = Properties.Resources.AboutBoxHeader, 49 | Text = Properties.Resources.AboutBoxText, 50 | ButtonContent = Properties.Resources.AboutBoxOk 51 | }; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Factories/Defaults/DefaultSigmaNotifyIconFactory.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Windows.Forms; 11 | 12 | namespace Sigma.Core.Monitors.WPF.View.Factories.Defaults 13 | { 14 | public sealed class DefaultSigmaNotifyIconFactory : SigmaNotifyIconFactory 15 | { 16 | public DefaultSigmaNotifyIconFactory(string iconResource, Action maximise, Action forceClose) 17 | { 18 | MenuItem[] items = new MenuItem[2]; 19 | 20 | items[0] = new MenuItem(Properties.Resources.OpenApp) { DefaultItem = true }; 21 | items[0].Click += (sender, args) => maximise(); 22 | 23 | items[1] = new MenuItem(Properties.Resources.CloseApp); 24 | items[1].Click += (sender, args) => forceClose(); 25 | 26 | Init("Sigma", iconResource, (sender, args) => maximise(), items); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Factories/Defaults/LoadingIndicatorFactory.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | 12 | namespace Sigma.Core.Monitors.WPF.View.Factories.Defaults 13 | { 14 | /// 15 | /// A factory that can create a loading indicator. 16 | /// 17 | public class LoadingIndicatorFactory : IUIFactory 18 | { 19 | private static readonly LoadingIndicatorFactory _factory; 20 | /// 21 | /// The singleton of the factory. 22 | /// 23 | public static LoadingIndicatorFactory Factory => _factory; 24 | 25 | static LoadingIndicatorFactory() 26 | { 27 | _factory = new LoadingIndicatorFactory(); 28 | } 29 | 30 | private LoadingIndicatorFactory() { } 31 | 32 | /// 33 | public UIElement CreateElement(Application app, Window window, params object[] parameters) 34 | { 35 | StackPanel panel = new StackPanel 36 | { 37 | VerticalAlignment = VerticalAlignment.Center, 38 | HorizontalAlignment = HorizontalAlignment.Center 39 | }; 40 | 41 | ProgressBar loading = new ProgressBar 42 | { 43 | Value = 0, 44 | IsIndeterminate = true, 45 | Style = Application.Current.Resources["MaterialDesignCircularProgressBar"] as Style 46 | }; 47 | 48 | loading.Width = loading.Height = 128; 49 | 50 | panel.Children.Add(loading); 51 | 52 | return panel; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Factories/Defaults/RootPanelFactory.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/View/Factories/Defaults/RootPanelFactory.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Factories/Defaults/StatusBar/StatusBarFactory.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/View/Factories/Defaults/StatusBar/StatusBarFactory.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Factories/Defaults/StatusBar/StatusBarLegendFactory.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/View/Factories/Defaults/StatusBar/StatusBarLegendFactory.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Factories/Defaults/TabControlFactory.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/View/Factories/Defaults/TabControlFactory.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Factories/UIFactory.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/View/Factories/UIFactory.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/Defaults/SigmaCheckBox.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/Defaults/SigmaComboBox.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/Defaults/SigmaDynamicGenericBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace Sigma.Core.Monitors.WPF.View.Parameterisation.Defaults 5 | { 6 | /// 7 | /// This is a generic text box that automatically uses the type of the registry in order to correctly display and parse to / from the value. 8 | /// 9 | /// It is necessary for XAML or other cases where generics are not possible. 10 | /// 11 | public class SigmaDynamicGenericBox : SigmaTextBox 12 | { 13 | /// 14 | /// The converter that converts the given type for the registry 15 | /// 16 | public TypeConverter Converter { get; protected set; } 17 | 18 | /// 19 | /// The current value that is displayed 20 | /// 21 | public object CurrentValue { get; protected set; } 22 | 23 | /// 24 | /// Force the visualiser to update its value (i.e. display the value that is stored). 25 | /// 26 | public override void Read() 27 | { 28 | object obj = SynchronisationHandler.SynchroniseGet(Registry, Key); 29 | 30 | if (Converter == null && obj != null) 31 | { 32 | Converter = TypeDescriptor.GetConverter(obj.GetType()); 33 | } 34 | 35 | if (obj != null) 36 | { 37 | CurrentValue = obj; 38 | Text = obj.ToString(); 39 | } 40 | } 41 | 42 | /// 43 | /// Force the visualiser to store its value (i.e. write the value that is displayed to the registry). 44 | /// 45 | public override void Write() 46 | { 47 | try 48 | { 49 | object convertedVal = Converter.ConvertFromString(Text); 50 | Pending = true; 51 | SynchronisationHandler.SynchroniseSet(Registry, Key, convertedVal, val => Pending = false, e => Errored = true); 52 | } 53 | catch (Exception) 54 | { 55 | Errored = true; 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/Defaults/SigmaSlider.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/Defaults/SigmaTextBlock.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/Defaults/SigmaTextBox.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/Defaults/SigmaTimeBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Sigma.Core.Monitors.WPF.ViewModel.Parameterisation; 3 | 4 | namespace Sigma.Core.Monitors.WPF.View.Parameterisation.Defaults 5 | { 6 | //TODO: editable time box (timepicker) 7 | //[ParameterVisualiser(typeof(DateTime), Priority = VisualiserPriority.Lower)] 8 | //public class SigmaTimeBox : SigmaTextBox 9 | //{ 10 | 11 | //} 12 | 13 | /// 14 | /// A TimeBlock that allows to display the current time. 15 | /// 16 | [ParameterVisualiser(typeof(DateTime), Priority = VisualiserPriority.Lower)] 17 | public class SigmaTimeBlock : SigmaTextBlock 18 | { 19 | /// 20 | public override object Object 21 | { 22 | get { return _Object; } 23 | set 24 | { 25 | if (_Object is DateTime) 26 | { 27 | _Object = value; 28 | TextBlock.Text = ((DateTime) Object).ToString(FormatString); 29 | } 30 | else 31 | { 32 | base.Object = value; 33 | } 34 | } 35 | } 36 | 37 | /// 38 | /// The string that is used to format the time. 39 | /// null, if default formatting should be applied. 40 | /// 41 | public string FormatString { get; set; } 42 | 43 | /// 44 | /// Create a label that is capable of displaying a time. 45 | /// 46 | public SigmaTimeBlock() 47 | { 48 | base.IsReadOnly = true; 49 | } 50 | 51 | /// 52 | /// Determines whether the parameter is editable or not. 53 | /// 54 | public sealed override bool IsReadOnly 55 | { 56 | get { return base.IsReadOnly; } 57 | set { throw new NotImplementedException(); } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/ParameterView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/Parameterisation/ParameterVisualiserInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.ComponentModel; 11 | using Sigma.Core.Monitors.WPF.Annotations; 12 | using Sigma.Core.Monitors.WPF.ViewModel.Parameterisation; 13 | 14 | namespace Sigma.Core.Monitors.WPF.View.Parameterisation 15 | { 16 | /// 17 | /// The default implementation for so it is easy to add new items (and nobody implements it badly). 18 | /// 19 | public class ParameterVisualiserInfo : IParameterVisualiserInfo 20 | { 21 | /// 22 | public Type Type { get; } 23 | 24 | /// 25 | public VisualiserPriority Priority { get; set; } 26 | 27 | /// 28 | public bool IsGeneric { get; } 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The type the is responsible for. 34 | /// The priority of the info. (higher prioriuty overrides lower ones). 35 | /// Determinse whether the given visualiser is generic or not. 36 | /// If bad enum is passed. 37 | /// If is null. 38 | public ParameterVisualiserInfo([NotNull] Type type, VisualiserPriority priority = VisualiserPriority.Normal, bool isGeneric = false) 39 | { 40 | if (type == null) throw new ArgumentNullException(nameof(type)); 41 | if (!Enum.IsDefined(typeof(VisualiserPriority), priority)) 42 | { 43 | throw new InvalidEnumArgumentException(nameof(priority), (int)priority, typeof(VisualiserPriority)); 44 | } 45 | 46 | Type = type; 47 | Priority = priority; 48 | IsGeneric = isGeneric; 49 | } 50 | 51 | 52 | } 53 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/View/UIWrapper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Windows.Controls; 10 | 11 | // ReSharper disable InconsistentNaming 12 | 13 | namespace Sigma.Core.Monitors.WPF.View 14 | { 15 | /// 16 | /// This class is a wrapper for s. 17 | /// It is often required that the functionality of those is wrapped; 18 | /// simply extend from this class and implement your custom behaviour. 19 | /// 20 | /// The type that is wrapped. 21 | public abstract class UIWrapper where T : ContentControl, new() 22 | { 23 | /// 24 | /// The content that is contained. 25 | /// 26 | protected T Content; 27 | 28 | /// 29 | /// Create a new with a new T (e.g. new TabItem) as content. 30 | /// 31 | protected UIWrapper() : this(new T()) 32 | { 33 | } 34 | 35 | /// 36 | /// Create a new with a passed T as content. 37 | /// 38 | /// The data that will be set to content. 39 | protected UIWrapper(T content) 40 | { 41 | Content = content; 42 | } 43 | 44 | /// 45 | /// Property for the content. (The actual data which is wrapped). If you want to 46 | /// set the content of the use WrappedContent.Content. 47 | /// 48 | public T WrappedContent 49 | { 50 | get { return Content; } 51 | set { Content = value; } 52 | } 53 | 54 | /// 55 | /// Convert the to the wrapped content. 56 | /// 57 | /// The wrapper containing the content. 58 | public static explicit operator T(UIWrapper wrapper) 59 | { 60 | return wrapper.Content; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/ViewModel/Parameterisation/IParameterLabel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | namespace Sigma.Core.Monitors.WPF.ViewModel.Parameterisation 10 | { 11 | /// 12 | /// An interface for the label that describes the names of parameters. 13 | /// 14 | public interface IParameterLabel 15 | { 16 | /// 17 | /// Set the state of a visualiser to pending. 18 | /// 19 | /// The visualiser that has changed its state. 20 | void Pending(IParameterVisualiser visualiser); 21 | 22 | /// 23 | /// Set the state of a visualiser to errored. 24 | /// 25 | /// The visualiser that has changed its state. 26 | void Errored(IParameterVisualiser visualiser); 27 | 28 | /// 29 | /// Set the state of a visualiser to success (i.e. don't care anymore). 30 | /// 31 | /// The visualiser that has changed its state. 32 | void Success(IParameterVisualiser visualiser); 33 | } 34 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/ViewModel/Parameterisation/PollParameterHook.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Sigma.Core.Training.Hooks; 4 | using Sigma.Core.Utils; 5 | 6 | namespace Sigma.Core.Monitors.WPF.ViewModel.Parameterisation 7 | { 8 | /// 9 | /// A hook that updates a given IParameterVisualiser on a given TimeStep. 10 | /// 11 | [Serializable] 12 | public class PollParameterHook : BaseHook 13 | { 14 | /// 15 | /// The identifier for the currently active visualiser. 16 | /// 17 | protected const string VisualiserIdentifier = "visualiser"; 18 | 19 | /// 20 | /// Create a hook with a certain time step 21 | /// 22 | /// The time step. 23 | /// The visualisers that will be updated. 24 | public PollParameterHook(ITimeStep timestep, IParameterVisualiser visualiser) : base(timestep) 25 | { 26 | ParameterRegistry[VisualiserIdentifier] = visualiser; 27 | } 28 | 29 | /// 30 | /// Invoke this hook with a certain parameter registry if optional conditional criteria are satisfied. 31 | /// 32 | /// The registry containing the required values for this hook's execution. 33 | /// A helper resolver for complex registry entries (automatically cached). 34 | public override void SubInvoke(IRegistry registry, IRegistryResolver resolver) 35 | { 36 | try 37 | { 38 | ((IParameterVisualiser) ParameterRegistry[VisualiserIdentifier]).Read(); 39 | } 40 | catch (TaskCanceledException) 41 | { 42 | // TODO: log to console 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/ViewModel/StatusBar/IWPFTaskVisualizationManager.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Windows; 12 | using Sigma.Core.Monitors.WPF.View.CustomControls.StatusBar; 13 | using Sigma.Core.Utils; 14 | 15 | namespace Sigma.Core.Monitors.WPF.ViewModel.StatusBar 16 | { 17 | public interface IWpfTaskVisualizationManager : IDisposable 18 | { 19 | /// 20 | /// The s to keep track of. 21 | /// 22 | TaskVisualizer[] TaskVisualizers { get; } 23 | 24 | /// 25 | /// The indicator that will be shown when too many tasks are visible. 26 | /// 27 | UIElement MoreTasksIndicator { get; } 28 | 29 | /// 30 | /// An array of the active s. 31 | /// If there is no task, for an index, the task is null. 32 | /// 33 | ITaskObserver[] ActiveTasks { get; } 34 | 35 | /// 36 | /// A list of the pending tasks. 37 | /// 38 | List PendingTasks { get; } 39 | } 40 | } -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/ViewModel/TitleBar/TitleBarControl.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core.Monitors.WPF/ViewModel/TitleBar/TitleBarControl.cs -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/WPFController.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Threading; 10 | using System.Windows; 11 | 12 | namespace Sigma.Core.Monitors.WPF 13 | { 14 | internal class WPFController : Window 15 | { 16 | private WPFController() 17 | { 18 | 19 | } 20 | 21 | /// 22 | /// Start the WPF window in the same thread. 23 | /// 24 | internal static void Start() 25 | { 26 | new Application().Run(new WPFController()); 27 | } 28 | 29 | /// 30 | /// Start the WPF window asynchronously. 31 | /// 32 | internal static void StartInNewThread(ThreadPriority priority = ThreadPriority.Normal) 33 | { 34 | Thread wpfThread = new Thread(() => Start()); 35 | 36 | wpfThread.SetApartmentState(ApartmentState.STA); 37 | 38 | wpfThread.Priority = priority; 39 | 40 | wpfThread.Start(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/build/Sigma.Core.Monitors.WPF.template.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Sigma.Core.Monitors.WPF/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Sigma.Core/Architecture/INetworkArchitecture.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Collections.Generic; 10 | using Sigma.Core.Utils; 11 | 12 | namespace Sigma.Core.Architecture 13 | { 14 | /// 15 | /// A network architecture from which an actual network can be constructed. 16 | /// 17 | public interface INetworkArchitecture : IDeepCopyable 18 | { 19 | /// 20 | /// The total number of layers in this architecture. 21 | /// 22 | int LayerCount { get; } 23 | 24 | /// 25 | /// A registry containing all relevant parameters and sub-registries (e.g. layer constructs). 26 | /// 27 | IRegistry Registry { get; } 28 | 29 | /// 30 | /// Validate this network architecture. 31 | /// 32 | void Validate(); 33 | 34 | /// 35 | /// Resolve all layer names to be fully qualified. 36 | /// Note: Unresolved names are stored to guarantee consistency when changing the architecture and re-resolving the layer names. 37 | /// 38 | void ResolveAllNames(); 39 | 40 | /// 41 | /// Yield all layers in the order they should be processed. 42 | /// 43 | /// 44 | IEnumerable YieldLayerConstructsOrdered(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Sigma.Core/Architecture/InvalidNetworkArchitectureException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Runtime.Serialization; 11 | 12 | namespace Sigma.Core.Architecture 13 | { 14 | /// 15 | /// An exception that occurs when a networks architecture is invalid. Yup. 16 | /// 17 | public class InvalidNetworkArchitectureException : Exception 18 | { 19 | public InvalidNetworkArchitectureException(string message) : base(message) 20 | { 21 | } 22 | 23 | public InvalidNetworkArchitectureException(string message, Exception innerException) : base(message, innerException) 24 | { 25 | } 26 | 27 | protected InvalidNetworkArchitectureException(SerializationInfo info, StreamingContext context) : base(info, context) 28 | { 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sigma.Core/Architecture/Linear/Parallel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | 11 | namespace Sigma.Core.Architecture.Linear 12 | { 13 | /// 14 | /// A utility class for parallelising linear network architectures in various ways. 15 | /// 16 | public static class Parallel 17 | { 18 | public static LinearNetworkArchitecture Parallellise(params LinearNetworkArchitecture[] networks) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | 23 | public static LinearNetworkArchitecture Concatinate(params LinearNetworkArchitecture[] networks) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Sigma.Core/Data/Iterators/IDataIterator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Data.Datasets; 10 | using Sigma.Core.Handlers; 11 | using Sigma.Core.MathAbstract; 12 | using System.Collections.Generic; 13 | using Sigma.Core.Utils; 14 | 15 | namespace Sigma.Core.Data.Iterators 16 | { 17 | /// 18 | /// A data iterator which iterates over a dataset in blocks. 19 | /// Note: The blocks yielded are in the BatchTimeFeatures format, where Batch and Time are one-dimensional. 20 | /// 21 | public interface IDataIterator 22 | { 23 | /// 24 | /// The dataset underlying this data iterator. 25 | /// 26 | IDataset UnderlyingDataset { get; } 27 | 28 | /// 29 | /// A registry containing relevant parameters of and information about this data iterator. 30 | /// 31 | IRegistry Registry { get; } 32 | 33 | /// 34 | /// Yield a block from this data iterator for and with a certain handler within a certain environment. 35 | /// If no more blocks can be yielded, return null. 36 | /// 37 | /// The computation handler to fetch a block for (used for block creation and computations). 38 | /// The sigma environment within the block should be yielded. 39 | /// An iterator over blocks from the underlying dataset (until the dataset is fully traversed). 40 | IEnumerable> Yield(IComputationHandler handler, SigmaEnvironment environment); 41 | 42 | /// 43 | /// Create a shallow copy of this data iterator (copy relevant properties, keep dataset). 44 | /// Typically used to provide workers with independent sets of data iterators for the same underlying data. 45 | /// 46 | /// A shallow copy of this data iterator. 47 | IDataIterator ShallowCopy(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Sigma.Core/Data/Preprocessors/IRecordPreprocessor.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Data.Extractors; 10 | 11 | namespace Sigma.Core.Data.Preprocessors 12 | { 13 | /// 14 | /// Preprocessors are a type of extractor which modify the actual data instead of just reshaping it. 15 | /// They are in their own namespace separate from record extractors for a clearer conceptual distinction. 16 | /// 17 | public interface IRecordPreprocessor : IRecordExtractor 18 | { 19 | /// 20 | /// A flag indicating whether this preprocessor only affects the underlying data or also the shape of the data. 21 | /// Note: Most preprocessors only change the data (e.g. for normalisation) and not the data shape. 22 | /// This flag is useful for ordering, optimising and analysing preprocessing operations. 23 | /// 24 | bool AffectsDataShape { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sigma.Core/Data/Readers/IRecordReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Data.Extractors; 10 | using Sigma.Core.Data.Sources; 11 | using System; 12 | 13 | namespace Sigma.Core.Data.Readers 14 | { 15 | /// 16 | /// A record reader which reads a selected number of records from a data set source in a specific format (e.g. CSV). 17 | /// 18 | public interface IRecordReader : IDisposable 19 | { 20 | /// 21 | /// The underlying data set source. 22 | /// 23 | IDataSource Source { get; } 24 | 25 | /// 26 | /// Attach a certain record extractor to this record reader. 27 | /// 28 | /// The extractor to attach this reader to. 29 | /// The given extractor (for convenience). 30 | IRecordExtractor Extractor(IRecordExtractor extractor); 31 | 32 | /// 33 | /// Prepare this record reader and its underlying resources to be read. 34 | /// Note: This function may be called more than once (and subsequent calls should probably be ignored, depending on the implementation). 35 | /// 36 | void Prepare(); 37 | 38 | /// 39 | /// Reads a number of records in any format (therefore attached extractors must be compatible). 40 | /// This method is mostly used internally by extractors, which have to be compatible with the used record readers (so they know which data format to expect). 41 | /// 42 | /// The number of records to read. 43 | /// An object of the given type representing a collection of a given number of records. 44 | object Read(int numberOfRecords); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Sigma.Core/Data/Sources/IDataSource.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.IO; 11 | 12 | namespace Sigma.Core.Data.Sources 13 | { 14 | /// 15 | /// A data source (e.g. local file source or URL web source) which can be used to retrieve data streams (e.g. by record readers to populate datasets). 16 | /// 17 | public interface IDataSource : IDisposable 18 | { 19 | /// 20 | /// The name of this source (e.g. file name, URL). 21 | /// 22 | string ResourceName { get; } 23 | 24 | /// 25 | /// Indicates whether this is a seekable data source. 26 | /// Seekable sources can be loaded and reloaded partially, non-chunkable sources are pre-fetched in . 27 | /// 28 | bool Seekable { get; } 29 | 30 | /// 31 | /// Check whether the specified data source exists and can be retrieved. 32 | /// 33 | /// A boolean indicating whether the specified data set source exists. 34 | bool Exists(); 35 | 36 | /// 37 | /// Prepares this data source for retrieval via . 38 | /// For non-chunkable sources this includes loading the entire data set. 39 | /// Note: This function may be called more than once (and subsequent calls should probably be ignored, depending on the implementation). 40 | /// 41 | void Prepare(); 42 | 43 | /// 44 | /// Retrieves the data source via a stream. 45 | /// 46 | /// 47 | Stream Retrieve(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Sigma.Core/Dependencies/DiffSharp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core/Dependencies/DiffSharp.dll -------------------------------------------------------------------------------- /Sigma.Core/Handlers/Backends/Debugging/DebugReportException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | 11 | namespace Sigma.Core.Handlers.Backends.Debugging 12 | { 13 | public class DebugReportException : Exception 14 | { 15 | public object[] BadValues { get; } 16 | 17 | public DebugReportException(string message, params object[] badValues) : base(message) 18 | { 19 | BadValues = badValues; 20 | } 21 | 22 | public DebugReportException(string message, Exception innerException, params object[] badValues) : base(message, innerException) 23 | { 24 | BadValues = badValues; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sigma.Core/Handlers/Backends/ILapackBackend.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | namespace Sigma.Core.Handlers.Backends 10 | { 11 | /// 12 | /// A LAPACK backend interface consisting of a subset of the LAPACK standard functions. 13 | /// See http://www.netlib.org/lapack/ for details. 14 | /// 15 | public unsafe interface ILapackBackend 16 | { 17 | void Sgesv(int* n, int* nrhs, float* a, int* lda, int* ipiv, float* b, int* ldb, int* info); 18 | void Ssysv_(char* uplo, int* n, int* nrhs, float* a, int* lda, int* ipiv, float* b, int* ldb, float* work, int* lwork, int* info); 19 | void Sgetrf_(int* m, int* n, float* a, int* lda, int* ipiv, int* info); 20 | void Sgetri_(int* n, float* a, int* lda, int* ipiv, float* work, int* lwork, int* info); 21 | 22 | void Dgesv(int* n, int* nrhs, double* a, int* lda, int* ipiv, double* b, int* ldb, int* info); 23 | void Dsysv_(char* uplo, int* n, int* nrhs, double* a, int* lda, int* ipiv, double* b, int* ldb, double* work, int* lwork, int* info); 24 | void Dgetrf_(int* m, int* n, double* a, int* lda, int* ipiv, int* info); 25 | void Dgetri_(int* n, double* a, int* lda, int* ipiv, double* work, int* lwork, int* info); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Sigma.Core/Handlers/Backends/SigmaDiff/PlatformDependentUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using log4net; 11 | 12 | namespace Sigma.Core.Handlers.Backends.SigmaDiff 13 | { 14 | /// 15 | /// Utilities to handle platform dependent DLLs. 16 | /// 17 | internal static class PlatformDependentUtils 18 | { 19 | private static readonly ILog ClazzLogger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 20 | 21 | private static bool _checkedPlatformDependentLibraries; 22 | 23 | internal static void CheckPlatformDependentLibraries() 24 | { 25 | if (_checkedPlatformDependentLibraries) 26 | { 27 | return; 28 | } 29 | 30 | PlatformID pid = Environment.OSVersion.Platform; 31 | 32 | if (pid == PlatformID.Win32NT || pid == PlatformID.Win32S || pid == PlatformID.Win32Windows || pid == PlatformID.WinCE) 33 | { 34 | ClazzLogger.Debug("Detected Windows system, using windows libraries (.dll)."); 35 | } 36 | else if (pid == PlatformID.Unix) 37 | { 38 | ClazzLogger.Debug("Detected Unix systemdetected, using linux libraries (.so)."); 39 | } 40 | else if (pid == PlatformID.MacOSX) 41 | { 42 | ClazzLogger.Debug("Detected MacOSX system, using linux libraries (.so)."); 43 | } 44 | else if (pid == PlatformID.Xbox) 45 | { 46 | ClazzLogger.Warn("Detected XBOX system. An XBOX. Really? I'm not even mad. Letting CLR decide what libraries to load."); 47 | } 48 | else 49 | { 50 | ClazzLogger.Warn($"Detected not natively supported system with platform id {pid} (potato system?). Letting CLR decide what libraries to load."); 51 | } 52 | 53 | _checkedPlatformDependentLibraries = true; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Sigma.Core/Layers/BaseLayer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Handlers; 10 | using Sigma.Core.Utils; 11 | using System; 12 | 13 | namespace Sigma.Core.Layers 14 | { 15 | /// 16 | /// A basic base layer to simplify custom layer implementations of the ILayer interface. 17 | /// 18 | [Serializable] 19 | public abstract class BaseLayer : ILayer 20 | { 21 | public string Name { get; } 22 | public string[] ExpectedInputs { get; protected set; } = { "default" }; 23 | public string[] ExpectedOutputs { get; protected set; } = { "default" }; 24 | public string[] TrainableParameters { get; protected set; } = { }; 25 | public IRegistry Parameters { get; } 26 | 27 | /// 28 | /// Create a base layer with a certain unique name. 29 | /// Note: Do NOT change the signature of this constructor, it's used to dynamically instantiate layers. 30 | /// 31 | /// The unique name of this layer. 32 | /// The parameters to this layer. 33 | /// The handler to use for ndarray parameter creation. 34 | protected BaseLayer(string name, IRegistry parameters, IComputationHandler handler) 35 | { 36 | if (name == null) throw new ArgumentNullException(nameof(name)); 37 | if (parameters == null) throw new ArgumentNullException(nameof(parameters)); 38 | if (handler == null) throw new ArgumentNullException(nameof(parameters)); 39 | 40 | Name = name; 41 | Parameters = parameters; 42 | } 43 | 44 | public abstract void Run(ILayerBuffer buffer, IComputationHandler handler, bool trainingPass); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Sigma.Core/Layers/Cost/SquaredDifferenceCostLayer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using Sigma.Core.Architecture; 11 | using Sigma.Core.Handlers; 12 | using Sigma.Core.MathAbstract; 13 | using Sigma.Core.Utils; 14 | 15 | namespace Sigma.Core.Layers.Cost 16 | { 17 | /// 18 | /// A cost layer that calculates the squared difference between predictions and targets. 19 | /// 20 | [Serializable] 21 | public class SquaredDifferenceCostLayer : BaseCostLayer 22 | { 23 | public SquaredDifferenceCostLayer(string name, IRegistry parameters, IComputationHandler handler) : base(name, parameters, handler) 24 | { 25 | } 26 | 27 | protected override INumber CalculateCost(INDArray predictions, INDArray targets, IRegistry parameters, IComputationHandler handler) 28 | { 29 | INDArray difference = handler.Subtract(predictions, targets); 30 | INumber cost = handler.Sum(handler.Pow(difference, 2)); 31 | 32 | return cost; 33 | } 34 | 35 | public static LayerConstruct Construct(string name = "#-squaredcost", double importance = 1.0, string externalTargetsAlias = "external_targets", string externalCostAlias = "external_cost") 36 | { 37 | LayerConstruct construct = new LayerConstruct(name, typeof(SquaredDifferenceCostLayer)); 38 | 39 | return InitialiseBaseConstruct(construct, importance, externalTargetsAlias, externalCostAlias); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Sigma.Core/Layers/ILayerBuffer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Collections.Generic; 10 | using Sigma.Core.Utils; 11 | 12 | namespace Sigma.Core.Layers 13 | { 14 | /// 15 | /// A layer buffer containing all relevant inputs, outputs and parameters for a layer to work with in an iteration. 16 | /// 17 | public interface ILayerBuffer 18 | { 19 | /// 20 | /// The actual layer instance this buffer is for. 21 | /// 22 | ILayer Layer { get; } 23 | 24 | /// 25 | /// The parameters for a layer to work with. 26 | /// 27 | IRegistry Parameters { get; } 28 | 29 | /// 30 | /// Indicate the alias names of the input layers to be supplied externally. 31 | /// 32 | string[] ExternalInputs { get; } 33 | 34 | /// 35 | /// Indicate the alias names of the output layers to be supplied externally. 36 | /// 37 | string[] ExternalOutputs { get; } 38 | 39 | /// 40 | /// The alias-named inputs for a layer. 41 | /// 42 | IReadOnlyDictionary Inputs { get; } 43 | 44 | /// 45 | /// The alias-named outputs for a layer. 46 | /// 47 | IReadOnlyDictionary Outputs { get; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Sigma.Core/MathAbstract/Backends/SigmaDiff/NativeCpu/ADFloat32Number.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Diagnostics.CodeAnalysis; 11 | using DiffSharp.Interop.Float32; 12 | using Sigma.Core.Handlers.Backends.SigmaDiff; 13 | 14 | namespace Sigma.Core.MathAbstract.Backends.SigmaDiff.NativeCpu 15 | { 16 | /// 17 | /// A number with a float32 CPU-based in-system-memory backend Sigma.DiffSharp handle for tracing and AD operations. 18 | /// 19 | [SuppressMessage("ReSharper", "InconsistentNaming")] 20 | [Serializable] 21 | public class ADFloat32Number : ADNumber, IADFloat32NumberHandle 22 | { 23 | /// 24 | public DNumber Handle { get; private set; } 25 | 26 | public ADFloat32Number(float value) : base(value) 27 | { 28 | Handle = new DNumber(value); 29 | } 30 | 31 | public ADFloat32Number(DNumber numberHandle) : base(numberHandle.Value) 32 | { 33 | Handle = numberHandle; 34 | } 35 | 36 | internal override void SetValue(float value) 37 | { 38 | base.SetValue(value); 39 | 40 | Handle = new DNumber(value); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Sigma.Core/MathAbstract/INumber.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Utils; 10 | 11 | namespace Sigma.Core.MathAbstract 12 | { 13 | /// 14 | /// A single traceable mathematical value (i.e. number), used for interaction between ndarrays and handlers (is more expressive and faster). 15 | /// 16 | public interface INumber : ITraceable, IDeepCopyable 17 | { 18 | /// 19 | /// The underlying value. 20 | /// 21 | object Value { get; set; } 22 | 23 | /// 24 | /// Get the underlying value as another type. 25 | /// 26 | /// The other type. 27 | /// The value as the other type. 28 | TOther GetValueAs(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sigma.Core/MathAbstract/ITraceable.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Handlers; 10 | 11 | namespace Sigma.Core.MathAbstract 12 | { 13 | /// 14 | /// A traceable mathematical object. 15 | /// 16 | public interface ITraceable 17 | { 18 | /// 19 | /// The computation handler associated with this traceable object (null if none). 20 | /// 21 | IComputationHandler AssociatedHandler { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sigma.Core/Monitors/IMonitor.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using Sigma.Core.Utils; 11 | 12 | namespace Sigma.Core.Monitors 13 | { 14 | public interface IMonitor : IDisposable 15 | { 16 | /// 17 | /// This function will be called before the start of the monitor. 18 | /// 19 | void Initialise(); 20 | 21 | /// 22 | /// Start this . 23 | /// If the runs in a new , this function should block until the monitor is completely up and running. 24 | /// 25 | void Start(); 26 | 27 | /// 28 | /// Signal this to stop. This method should call dispose. 29 | /// This could for example stop the Sigma learning process (if mandatory), or clear up registry entries, resources ... 30 | /// 31 | void SignalStop(); 32 | 33 | /// 34 | /// The sigma environment associated with this monitor. 35 | /// 36 | SigmaEnvironment Sigma { get; set; } 37 | 38 | IRegistry Registry { get; set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Sigma.Core/Monitors/MonitorAdapter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Utils; 10 | 11 | namespace Sigma.Core.Monitors 12 | { 13 | public abstract class MonitorAdapter : IMonitor 14 | { 15 | public SigmaEnvironment Sigma { get; set; } 16 | public IRegistry Registry { get; set; } 17 | 18 | public virtual void Initialise() { } 19 | 20 | public abstract void Start(); 21 | 22 | public virtual void Dispose() { } 23 | 24 | public virtual void SignalStop() { } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sigma.Core/Monitors/Synchronisation/ISynchronisationSource.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Sigma.Core.Monitors.Synchronisation 4 | { 5 | /// 6 | /// A synchronisation source provides additional data for a synchronisation handler if a value cannot be found in the default registry. 7 | /// 8 | public interface ISynchronisationSource 9 | { 10 | /// 11 | /// Try to retrieve a value from this source (if existent). 12 | /// 13 | /// The type of the value that will be retrieved. 14 | /// The key of the value. 15 | /// The value itself that will be assigned if it could be retrieved, null otherwise. 16 | /// True if the source could retrieve given key, false otherwise. 17 | bool TryGet(string key, out T val); 18 | 19 | /// 20 | /// Try to set a value from this source (if existent). 21 | /// 22 | /// The type of the value that will be set. 23 | /// The key of the value. 24 | /// The value itself that will be assigned if it applicable. 25 | /// True if the source could set given key, false otherwise. 26 | bool TrySet(string key, T val); 27 | 28 | /// 29 | /// Determine whether a given key is contained / manged by this source. 30 | /// 31 | /// The key that will be checked. 32 | /// True if given key can be accessed with get / set, false otherwise. 33 | bool Contains(string key); 34 | 35 | /// 36 | /// This is a list of keys this source provides. It is completely optional, although it is recommended to implement it. 37 | /// 38 | /// Once a new source is added, the keys of the sources are checked against to determine double entries which makes debugging for users easier (as log entries are produced autoamtically). 39 | /// 40 | string[] Keys { get; } 41 | } 42 | } -------------------------------------------------------------------------------- /Sigma.Core/Parameterisation/IParameterType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | namespace Sigma.Core.Parameterisation 10 | { 11 | /// 12 | /// A parameter type for parameterisation utilities. 13 | /// 14 | public interface IParameterType 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sigma.Core/Parameterisation/Types/RangedParameterType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | 11 | namespace Sigma.Core.Parameterisation.Types 12 | { 13 | /// 14 | /// A ranged parameter type for a certain generic numeric type. 15 | /// 16 | public class RangedParameterType : IParameterType where T : IComparable 17 | { 18 | /// 19 | /// The minimum value of this parameter type. 20 | /// 21 | public T MinValue { get; } 22 | 23 | /// 24 | /// The maximum value of this parameter type. 25 | /// 26 | public T MaxValue { get; } 27 | 28 | /// 29 | /// The step size of this parameter type. 30 | /// 31 | public T StepSize { get; } 32 | 33 | /// 34 | /// Create a ranged parameter type with a certain minimum and maximum value and a certain step size. 35 | /// 36 | /// The minimum value. 37 | /// The maximum value. 38 | /// The step size. 39 | public RangedParameterType(T minValue, T maxValue, T stepSize) 40 | { 41 | MinValue = minValue; 42 | MaxValue = maxValue; 43 | StepSize = stepSize; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Sigma.Core/Persistence/ISerialisationNotifier.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | namespace Sigma.Core.Persistence 10 | { 11 | /// 12 | /// An interface to indicate to the Sigma tools that your object should get notified on serialisation events. 13 | /// Note: There is no OnDeserialising method because there is no guarantee that the used has access to the object before it's fully constructed. 14 | /// 15 | public interface ISerialisationNotifier 16 | { 17 | /// 18 | /// Called before this object is serialised. 19 | /// 20 | void OnSerialising(); 21 | 22 | /// 23 | /// Called after this object was serialised. 24 | /// 25 | void OnSerialised(); 26 | 27 | /// 28 | /// Called after this object was de-serialised. 29 | /// 30 | void OnDeserialised(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Sigma.Core/Persistence/Selectors/Network/DefaultNetworkSelector.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using Sigma.Core.Architecture; 11 | 12 | namespace Sigma.Core.Persistence.Selectors.Network 13 | { 14 | /// 15 | /// A default network selector, assuming the availability of a Network(string name) constructor. 16 | /// 17 | public class DefaultNetworkSelector : BaseNetworkSelector where TNetwork : INetwork 18 | { 19 | /// 20 | /// Create a base network selector for a network. 21 | /// Note: The network type must have a Network(string name) constructor. 22 | /// 23 | /// The network. 24 | public DefaultNetworkSelector(TNetwork result) : base(result) 25 | { 26 | } 27 | 28 | /// 29 | protected override TNetwork CreateNetwork(string name) 30 | { 31 | return (TNetwork) Activator.CreateInstance(Result.GetType(), name); 32 | } 33 | 34 | /// 35 | protected override INetworkSelector CreateSelector(TNetwork network) 36 | { 37 | return new DefaultNetworkSelector(network); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Sigma.Core/Persistence/Selectors/Operator/CpuMultithreadedOperatorSelector.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Training.Operators.Backends.NativeCpu; 10 | 11 | namespace Sigma.Core.Persistence.Selectors.Operator 12 | { 13 | /// 14 | /// An operator selector for s. 15 | /// 16 | public class CpuMultithreadedOperatorSelector : BaseOperatorSelector 17 | { 18 | /// 19 | /// Create a base operator selector with a certain operator. 20 | /// 21 | /// The operator. 22 | public CpuMultithreadedOperatorSelector(CpuMultithreadedOperator @operator) : base(@operator) 23 | { 24 | } 25 | 26 | /// 27 | /// Create an operator of this operator selectors appropriate type (take necessary constructor arguments from the current operator). 28 | /// 29 | /// The operator. 30 | protected override CpuMultithreadedOperator CreateOperator() 31 | { 32 | return new CpuMultithreadedOperator(Result.Handler, Result.WorkerCount, Result.WorkerPriority); 33 | } 34 | 35 | /// 36 | /// Create an operator selector with a certain operator. 37 | /// 38 | /// The operator 39 | /// An operator selector with the given operator. 40 | protected override IOperatorSelector CreateSelector(CpuMultithreadedOperator @operator) 41 | { 42 | return new CpuMultithreadedOperatorSelector(@operator); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sigma.Core/Persistence/Selectors/Operator/CpuSinglethreadedOperator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Training.Operators.Backends.NativeCpu; 10 | 11 | namespace Sigma.Core.Persistence.Selectors.Operator 12 | { 13 | /// 14 | /// An operator selector for s. 15 | /// 16 | public class CpuSinglethreadedOperatorSelector : BaseOperatorSelector 17 | { 18 | /// 19 | /// Create a base operator selector with a certain operator. 20 | /// 21 | /// The operator. 22 | public CpuSinglethreadedOperatorSelector(CpuSinglethreadedOperator @operator) : base(@operator) 23 | { 24 | } 25 | 26 | /// 27 | /// Create an operator of this operator selectors appropriate type (take necessary constructor arguments from the current operator). 28 | /// 29 | /// The operator. 30 | protected override CpuSinglethreadedOperator CreateOperator() 31 | { 32 | return new CpuSinglethreadedOperator(Result.Handler, Result.WorkerPriority); 33 | } 34 | 35 | /// 36 | /// Create an operator selector with a certain operator. 37 | /// 38 | /// The operator 39 | /// An operator selector with the given operator. 40 | protected override IOperatorSelector CreateSelector(CpuSinglethreadedOperator @operator) 41 | { 42 | return new CpuSinglethreadedOperatorSelector(@operator); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sigma.Core/Persistence/Selectors/Trainer/DefaultTrainerSelector.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using Sigma.Core.Training; 11 | 12 | namespace Sigma.Core.Persistence.Selectors.Trainer 13 | { 14 | /// A default network selector, assuming the availability of a Trainer(string name) constructor. 15 | public class DefaultTrainerSelector : BaseTrainerSelector where TTrainer : ITrainer 16 | { 17 | /// 18 | /// Create a base trainer selector for a certain trainer. 19 | /// Note: The trainer type must have a Trainer(string name) constructor. 20 | /// 21 | /// The type of the selected trainer. 22 | public DefaultTrainerSelector(TTrainer trainer) : base(trainer) 23 | { 24 | } 25 | 26 | /// 27 | /// Create a trainer with a certain name. 28 | /// 29 | /// The name. 30 | /// The trainer. 31 | public override TTrainer CreateTrainer(string name) 32 | { 33 | return (TTrainer) Activator.CreateInstance(Result.GetType(), name); 34 | } 35 | 36 | /// 37 | /// Create a selector for a certain trainer. 38 | /// 39 | /// The trainer. 40 | /// The selector. 41 | public override ITrainerSelector CreateSelector(TTrainer trainer) 42 | { 43 | return new DefaultTrainerSelector(trainer); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Sigma.Core/Persistence/Serialiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.IO; 10 | using System.Runtime.Serialization.Formatters.Binary; 11 | 12 | namespace Sigma.Core.Persistence 13 | { 14 | /// 15 | /// An abstract serialiser interface for various serialisation formats (beyond C# Formatter variants). 16 | /// 17 | public interface ISerialiser 18 | { 19 | /// 20 | /// Write an object to a stream. 21 | /// 22 | /// The object to write. 23 | /// The stream to write to. 24 | void Write(object obj, Stream stream); 25 | 26 | /// 27 | /// Read an object from a stream. 28 | /// 29 | /// The stream to read from.. 30 | /// The read object. 31 | object Read(Stream stream); 32 | } 33 | 34 | /// 35 | /// A collection of available serialisers. 36 | /// 37 | public static class Serialisers 38 | { 39 | /// 40 | /// A binary serialiser. 41 | /// 42 | public static readonly ISerialiser BinarySerialiser = new BinarySerialiser(); 43 | } 44 | 45 | /// 46 | /// A binary serialiser, using the . 47 | /// 48 | public class BinarySerialiser : ISerialiser 49 | { 50 | public void Write(object obj, Stream stream) 51 | { 52 | new BinaryFormatter().Serialize(stream, obj); 53 | } 54 | 55 | public object Read(Stream stream) 56 | { 57 | return new BinaryFormatter().Deserialize(stream); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Sigma.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Reflection; 10 | using System.Runtime.InteropServices; 11 | 12 | // General Information about an assembly is controlled through the following 13 | // set of attributes. Change these attribute values to modify the information 14 | // associated with an assembly. 15 | [assembly: AssemblyTitle("Sigma.Core")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyConfiguration("")] 18 | [assembly: AssemblyCompany("GreekDictionary")] 19 | [assembly: AssemblyProduct("Sigma.Core")] 20 | [assembly: AssemblyCopyright("Copyright © 2016 Florian Cäsar, Michael Plainer")] 21 | [assembly: AssemblyTrademark("")] 22 | [assembly: AssemblyCulture("")] 23 | 24 | // Setting ComVisible to false makes the types in this assembly not visible 25 | // to COM components. If you need to access a type in this assembly from 26 | // COM, set the ComVisible attribute to true on that type. 27 | [assembly: ComVisible(false)] 28 | 29 | // The following GUID is for the ID of the typelib if this project is exposed to COM 30 | [assembly: Guid("92b1bb1d-7f6a-4bd7-820c-46454f9af8b3")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] 44 | -------------------------------------------------------------------------------- /Sigma.Core/Sigma.Core.licenseheader: -------------------------------------------------------------------------------- 1 | extensions: .cs 2 | /* 3 | MIT License 4 | 5 | Copyright (c) 2016-%CurrentYear% Florian Cäsar, Michael Plainer 6 | 7 | For full license see LICENSE in the root directory of this project. 8 | */ 9 | -------------------------------------------------------------------------------- /Sigma.Core/Sigma.Core.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sigma.Core 5 | $version$ 6 | Sigma.Core 7 | ThinkingTransistor 8 | ThinkingTransistor 9 | https://github.com/ThinkingTransistor/Sigma/blob/master/LICENSE 10 | https://sigma.rocks 11 | https://sigma.rocks/logo.png 12 | true 13 | Rocket powered machine learning. Create, compare, adapt, improve - neural networks at the speed of thought. 14 | $summary$ 15 | Copyright 2016-2017 (MIT) 16 | machine-learning neural-network artificial-intelligence artificial-neural-networks framework 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Hooks/IllegalHookDependencyException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | 11 | namespace Sigma.Core.Training.Hooks 12 | { 13 | /// 14 | /// An exception that occurs if a hook dependency is not legal and the hook manager there does not know what to do. 15 | /// 16 | public class IllegalHookDependencyException : Exception 17 | { 18 | public IllegalHookDependencyException(string message) : base(message) 19 | { 20 | } 21 | 22 | public IllegalHookDependencyException(string message, Exception innerException) : base(message, innerException) 23 | { 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Hooks/LambdaHook.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Utils; 10 | using System; 11 | 12 | namespace Sigma.Core.Training.Hooks 13 | { 14 | /// 15 | /// A utility lambda hook for miscellaneous things and debugging. 16 | /// Note: Lambda hooks are not serialisable. 17 | /// 18 | public class LambdaHook : BaseHook 19 | { 20 | /// 21 | /// Create a hook with a certain time step and a set of required global registry entries. 22 | /// 23 | /// The time step. 24 | /// The action that will be invoked in . 25 | /// The required global registry entries. 26 | public LambdaHook(ITimeStep timestep, Action invokeAction, params string[] requiredRegistryEntries) : base(timestep, requiredRegistryEntries) 27 | { 28 | ParameterRegistry["invoke_action"] = invokeAction; 29 | } 30 | 31 | /// 32 | /// Invoke this hook with a certain parameter registry. 33 | /// 34 | /// The registry containing the required values for this hook's execution. 35 | /// A helper resolver for complex registry entries (automatically cached). 36 | public override void SubInvoke(IRegistry registry, IRegistryResolver resolver) 37 | { 38 | Action action = ParameterRegistry.Get>("invoke_action"); 39 | action.Invoke(registry, resolver); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Hooks/Processors/TimeSeriesGeneratorHook.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Sigma.Core.Architecture; 3 | using Sigma.Core.Training.Providers; 4 | using Sigma.Core.Utils; 5 | 6 | namespace Sigma.Core.Training.Hooks.Processors 7 | { 8 | public class TimeSeriesGeneratorHook : BaseHook 9 | { 10 | /// 11 | /// Create a hook with a certain time step and a set of required global registry entries. 12 | /// 13 | /// The time step. 14 | /// The required global registry entries. 15 | public TimeSeriesGeneratorHook(ITimeStep timestep) : base(timestep, "network.self") 16 | { 17 | } 18 | 19 | /// 20 | /// Invoke this hook with a certain parameter registry if optional conditional criteria are satisfied. 21 | /// 22 | /// The registry containing the required values for this hook's execution. 23 | /// A helper resolver for complex registry entries (automatically cached). 24 | public override void SubInvoke(IRegistry registry, IRegistryResolver resolver) 25 | { 26 | INetwork network = resolver.ResolveGetSingle("network.self"); 27 | 28 | //DataUtils.ProvideExternalInputData(network, DataUtils.MakeBlock()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Hooks/Reporters/CurrentEpochIterationReporter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using log4net; 11 | using Sigma.Core.Utils; 12 | 13 | namespace Sigma.Core.Training.Hooks.Reporters 14 | { 15 | /// 16 | /// A reporter hook that reports the current epoch and iteration. 17 | /// 18 | [Serializable] 19 | public class CurrentEpochIterationReporter : BaseHook 20 | { 21 | [NonSerialized] 22 | private readonly ILog _logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 23 | 24 | /// 25 | /// Create a hook with a certain time step and a set of required global registry entries. 26 | /// 27 | /// The time step. 28 | /// The format string used (arg 0 is epoch, arg 1 is iteration). 29 | public CurrentEpochIterationReporter(ITimeStep timestep, string format = "Epoch: {0} / Iteration: {1}") : base(timestep, "epoch", "iteration") 30 | { 31 | InvokePriority = -10000; // typically this should be invoked first 32 | ParameterRegistry["format_string"] = format; 33 | } 34 | 35 | /// 36 | /// Invoke this hook with a certain parameter registry. 37 | /// 38 | /// The registry containing the required values for this hook's execution. 39 | /// A helper resolver for complex registry entries (automatically cached). 40 | public override void SubInvoke(IRegistry registry, IRegistryResolver resolver) 41 | { 42 | int epoch = registry.Get("epoch"); 43 | int iteration = registry.Get("iteration"); 44 | 45 | Report(epoch, iteration); 46 | } 47 | 48 | protected virtual void Report(int epoch, int iteration) 49 | { 50 | _logger.Info(string.Format(ParameterRegistry.Get("format_string"), epoch, iteration)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Hooks/TargetMode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | namespace Sigma.Core.Training.Hooks 10 | { 11 | /// 12 | /// The target mode for a particular hook. 13 | /// Used to implicitly add it to local / global hooks if specified, otherwise (if marked as require explicit call. 14 | /// Note: Target mode does not have to match the actual target of a hook. It's merely a recommendation. 15 | /// 16 | public enum TargetMode 17 | { 18 | /// 19 | /// The local target mode, prefer per-worker invocation. 20 | /// 21 | Local, 22 | 23 | /// 24 | /// The global target mode, prefer per-operator invocation. 25 | /// 26 | Global, 27 | 28 | /// 29 | /// The default any target mode, no preference given. Requires explicit call to attach as hook. 30 | /// 31 | Any 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Initialisers/CustomInitialiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | 11 | namespace Sigma.Core.Training.Initialisers 12 | { 13 | /// 14 | /// A custom initialiser adapter for simple initialiser assignment with lambdas. 15 | /// 16 | public class CustomInitialiser : BaseInitialiser 17 | { 18 | private readonly Func _valueFunc; 19 | 20 | /// 21 | /// Create a custom initialiser with a given per value function. 22 | /// 23 | /// The value function with the inputs indices, shape and a randomiser and the output value at the given index. 24 | public CustomInitialiser(Func valueFunc) 25 | { 26 | if (valueFunc == null) throw new ArgumentNullException(nameof(valueFunc)); 27 | 28 | _valueFunc = valueFunc; 29 | } 30 | 31 | public override object GetValue(long[] indices, long[] shape, Random random) 32 | { 33 | return _valueFunc(indices, shape, random); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Initialisers/GaussianInitialiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | 11 | namespace Sigma.Core.Training.Initialisers 12 | { 13 | /// 14 | /// A Gaussian initialiser for ndarrays with mean and standard deviation. 15 | /// 16 | [Serializable] 17 | public class GaussianInitialiser : BaseInitialiser 18 | { 19 | /// 20 | /// Create a Gaussian initialiser with a certain standard deviation and optional mean. 21 | /// 22 | /// The standard deviation. 23 | /// The mean. 24 | public GaussianInitialiser(double standardDeviation, double mean = 0.0) 25 | { 26 | Registry.Set("mean", mean, typeof(double)); 27 | Registry.Set("standard_deviation", standardDeviation, typeof(double)); 28 | } 29 | 30 | public override object GetValue(long[] indices, long[] shape, Random random) 31 | { 32 | // box-muller transform for fast Gaussian values 33 | // see http://stackoverflow.com/questions/218060/random-gaussian-variables 34 | double u1 = random.NextDouble(); 35 | double u2 = random.NextDouble(); 36 | double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2); 37 | 38 | return Registry.Get("mean") + Registry.Get("standard_deviation") * randStdNormal; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Initialisers/IInitialiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Handlers; 10 | using Sigma.Core.MathAbstract; 11 | using System; 12 | using Sigma.Core.Utils; 13 | 14 | namespace Sigma.Core.Training.Initialisers 15 | { 16 | /// 17 | /// An initialiser that can be used to initialise any ndarray with a certain pattern (e.g. Gaussian). 18 | /// 19 | public interface IInitialiser 20 | { 21 | /// 22 | /// The registry containing relevant parameters and information about this initialiser. 23 | /// 24 | IRegistry Registry { get; } 25 | 26 | /// 27 | /// Initialise a certain ndarray. 28 | /// 29 | /// The ndarray to initialise. 30 | /// The computation handler to use. 31 | /// The randomiser to use (if required). 32 | void Initialise(INDArray array, IComputationHandler handler, Random random); 33 | 34 | /// 35 | /// Initialise a single number. 36 | /// 37 | /// The number to initialise. 38 | /// The computation handler to use. 39 | /// The randomise to use (if required). 40 | void Initialise(INumber number, IComputationHandler handler, Random random); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Initialisers/XavierInitialiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using Sigma.Core.Utils; 11 | 12 | namespace Sigma.Core.Training.Initialisers 13 | { 14 | [Serializable] 15 | public class XavierInitialiser : BaseInitialiser 16 | { 17 | /// 18 | /// Create a Xavier style initialiser with a certain mean and scale. 19 | /// The standard deviation is calculated as scale / ndarray.Length. 20 | /// 21 | /// 22 | /// The mean. 23 | public XavierInitialiser(double scale = 1.0, double mean = 0.0) 24 | { 25 | Registry.Set("mean", mean, typeof(double)); 26 | Registry.Set("scale", scale, typeof(double)); 27 | } 28 | 29 | /// 30 | /// Get the value to set for certain indices shape and a helper randomiser. 31 | /// 32 | /// The indices. 33 | /// The shape. 34 | /// The randomiser. 35 | /// The value to set at the given indices. 36 | public override object GetValue(long[] indices, long[] shape, Random random) 37 | { 38 | // box-muller transform for fast Gaussian values 39 | // see http://stackoverflow.com/questions/218060/random-gaussian-variables 40 | double u1 = random.NextDouble(); 41 | double u2 = random.NextDouble(); 42 | double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2); 43 | double standardDeviation = Registry.Get("scale") / ArrayUtils.Product(shape); 44 | 45 | return Registry.Get("mean") + standardDeviation * randStdNormal; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Mergers/MaxNetworkMerger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Sigma.Core.Handlers; 4 | using Sigma.Core.MathAbstract; 5 | 6 | namespace Sigma.Core.Training.Mergers 7 | { 8 | /// 9 | /// A network manager that uses the highest value. 10 | /// 11 | public class MaxNetworkMerger : BaseNetworkMerger 12 | { 13 | /// 14 | /// This method is used to merge doubles. 15 | /// 16 | /// The doubles. 17 | /// The merged value. 18 | protected override double MergeDoubles(double[] doubles) 19 | { 20 | return doubles.Max(); 21 | } 22 | 23 | /// 24 | /// This method is used to merge s. 25 | /// 26 | /// The arrays to merge. 27 | /// The handler that may or may not be specified. 28 | /// A merged . 29 | protected override INDArray MergeNDArrays(INDArray[] arrays, IComputationHandler handler) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | 34 | /// 35 | /// This method is used to merge s. 36 | /// 37 | /// The numbers to merge. 38 | /// The handler that may or may not be specified. 39 | /// A merged . 40 | protected override INumber MergeNumbers(INumber[] numbers, IComputationHandler handler) 41 | { 42 | throw new NotImplementedException(); 43 | //? return numbers.Max(); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Sigma.Core/Training/Modifiers/ClipValueModifier.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using Sigma.Core.Handlers; 11 | using Sigma.Core.MathAbstract; 12 | 13 | namespace Sigma.Core.Training.Modifiers 14 | { 15 | /// 16 | /// A clip value modifier that clips all parameters to a certain range. 17 | /// 18 | [Serializable] 19 | public class ClipValueModifier : BaseValueModifier 20 | { 21 | /// 22 | /// Create a clip value modifier that clips all values to a certain range (defaults to [-1, 1]). 23 | /// 24 | /// The optional minimum value. 25 | /// The optional maximum value. 26 | public ClipValueModifier(double minValue = -1.0, double maxValue = 1.0) 27 | { 28 | Registry["min_value"] = minValue; 29 | Registry["max_value"] = maxValue; 30 | } 31 | 32 | public override INDArray Modify(string paramIdentifier, INDArray parameter, IComputationHandler handler) 33 | { 34 | INumber minValue = handler.Number(Registry.Get("min_value")); 35 | INumber maxValue = handler.Number(Registry.Get("max_value")); 36 | 37 | return handler.Clip(parameter, minValue, maxValue); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Modifiers/IValueModifier.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Handlers; 10 | using Sigma.Core.MathAbstract; 11 | using Sigma.Core.Utils; 12 | 13 | namespace Sigma.Core.Training.Modifiers 14 | { 15 | /// 16 | /// A value modifier that modifies ndarrays and numbers according to some specification. 17 | /// 18 | public interface IValueModifier 19 | { 20 | /// 21 | /// The registry containing this value modifier's parameter for external inspection and modification (if applicable). 22 | /// 23 | IRegistry Registry { get; } 24 | 25 | /// 26 | /// Modify a certain ndarray with a certain identifier. 27 | /// 28 | /// The parameter identifier. 29 | /// The parameter to modify. 30 | /// The computation handler to use. 31 | /// The modified parameter. 32 | INDArray Modify(string paramIdentifier, INDArray parameter, IComputationHandler handler); 33 | 34 | /// 35 | /// Modify a certain number with a certain identifier. 36 | /// 37 | /// The parameter identifier. 38 | /// The parameter to modify. 39 | /// The computation handler to use. 40 | /// The modified parameter. 41 | INumber Modify(string paramIdentifier, INumber parameter, IComputationHandler handler); 42 | 43 | /// 44 | /// Modify a certain number with a certain identifier. 45 | /// 46 | /// The parameter identifier. 47 | /// The parameter to modify. 48 | /// The computation handler to use. 49 | /// The modified parameter. 50 | double Modify(string paramIdentifier, double parameter, IComputationHandler handler); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Modifiers/ScaleValueModifier.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using Sigma.Core.Handlers; 11 | using Sigma.Core.MathAbstract; 12 | 13 | namespace Sigma.Core.Training.Modifiers 14 | { 15 | /// 16 | /// A scale value modifier to scale certain values such that x = x * scale. 17 | /// 18 | [Serializable] 19 | public class ScaleValueModifier : BaseValueModifier 20 | { 21 | /// 22 | /// Create a scale value modifier with a certain scale. 23 | /// 24 | /// The scale. 25 | public ScaleValueModifier(double scale) 26 | { 27 | Registry.Set("scale", scale, typeof(double)); 28 | } 29 | 30 | /// 31 | /// Modify a certain ndarray with a certain identifier. 32 | /// 33 | /// The parameter identifier. 34 | /// The parameter to modify. 35 | /// The computation handler to use. 36 | /// The modified parameter. 37 | public override INDArray Modify(string paramIdentifier, INDArray parameter, IComputationHandler handler) 38 | { 39 | return handler.Multiply(parameter, Registry.Get("scale")); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Sigma.Core/Training/Operators/Backends/NativeCpu/Workers/CpuWorker.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Threading; 10 | using log4net; 11 | using Sigma.Core.Handlers; 12 | using Sigma.Core.Training.Operators.Workers; 13 | 14 | namespace Sigma.Core.Training.Operators.Backends.NativeCpu.Workers 15 | { 16 | /// 17 | /// A worker that executes its operations on the cpu with a cpu backend (default behavior in base worker, separate class for future proofing). 18 | /// 19 | public class CpuWorker : BaseWorker 20 | { 21 | private ILog Logger => _logger ?? (_logger = LogManager.GetLogger(GetType())); 22 | private ILog _logger; 23 | 24 | public CpuWorker(IOperator @operator) : base(@operator) { } 25 | 26 | public CpuWorker(IOperator @operator, IComputationHandler handler) : base(@operator, handler) { } 27 | 28 | public CpuWorker(IOperator @operator, IComputationHandler handler, ThreadPriority priority) : base(@operator, handler, priority) { } 29 | 30 | /// 31 | protected override void OnPause() 32 | { 33 | } 34 | 35 | /// 36 | protected override void OnResume() 37 | { 38 | } 39 | 40 | /// 41 | protected override void OnStop() 42 | { 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Sigma.Core/Training/Operators/ExecutionState.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | namespace Sigma.Core.Training.Operators 10 | { 11 | /// 12 | /// An state for diverse training tasks. 13 | /// 14 | public enum ExecutionState 15 | { 16 | None, 17 | Running, 18 | Paused, 19 | Stopped 20 | } 21 | } -------------------------------------------------------------------------------- /Sigma.Core/Training/Optimisers/Gradient/GradientDescentOptimiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using Sigma.Core.Handlers; 11 | using Sigma.Core.MathAbstract; 12 | 13 | namespace Sigma.Core.Training.Optimisers.Gradient 14 | { 15 | /// 16 | /// A gradient descent optimiser, using the classic gradient descent algorithm with a certain learning rate on each parameter. 17 | /// The parameter update rule is: 18 | /// parameter = parameter - gradient * learning_rate 19 | /// 20 | [Serializable] 21 | public class GradientDescentOptimiser : BaseGradientOptimiser 22 | { 23 | /// 24 | /// Create a gradient descent optimiser with a certain learning rate. 25 | /// 26 | /// The learning rate. 27 | /// The optional external output identifier by which to detect cost layers (defaults to "external_cost"). 28 | public GradientDescentOptimiser(double learningRate, string externalCostAlias = "external_cost") : base(externalCostAlias) 29 | { 30 | Registry.Set("learning_rate", learningRate, typeof(double)); 31 | } 32 | 33 | internal override INDArray Optimise(string paramIdentifier, INDArray parameter, INDArray gradient, IComputationHandler handler) 34 | { 35 | INDArray update = handler.Multiply(gradient, -Registry.Get("learning_rate")); 36 | 37 | ExposeParameterUpdate(paramIdentifier, update); 38 | 39 | return handler.Add(parameter, update); 40 | } 41 | 42 | /// 43 | /// Deep copy this object. 44 | /// 45 | /// A deep copy of this object. 46 | protected override BaseGradientOptimiser ShallowCopyParameters() 47 | { 48 | return new GradientDescentOptimiser(learningRate: Registry.Get("learning_rate"), externalCostAlias: ExternalCostAlias); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Sigma.Core/Utils/IDeepCopyable.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | namespace Sigma.Core.Utils 10 | { 11 | /// 12 | /// A deep copyable object. "Deep" means all child references are recursively copied down to actual copyable primitives. 13 | /// Note: If some members cannot be deep copied, they may be shallow copied or left out, assuming the object is still in a valid state for the required task (e.g. seek content). 14 | /// 15 | public interface IDeepCopyable 16 | { 17 | /// 18 | /// Deep copy this object. 19 | /// 20 | /// A deep copy of this object. 21 | object DeepCopy(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sigma.Core/Utils/IEnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | 13 | namespace Sigma.Core.Utils 14 | { 15 | // ReSharper disable once InconsistentNaming 16 | public static class IEnumerableExtensions 17 | { 18 | public static int IndexOf(this IEnumerable source, T item) 19 | { 20 | var entry = source 21 | .Select((x, i) => new { Value = x, Index = i }) 22 | .FirstOrDefault(x => Equals(x.Value, item)); 23 | return entry?.Index ?? -1; 24 | } 25 | 26 | public static void CopyTo(this IEnumerable source, T[] array, int startIndex) 27 | { 28 | int lowerBound = array.GetLowerBound(0); 29 | int upperBound = array.GetUpperBound(0); 30 | 31 | if (startIndex < lowerBound) 32 | throw new ArgumentOutOfRangeException(nameof(startIndex), "The start index must be greater than or equal to the array lower bound"); 33 | if (startIndex > upperBound) 34 | throw new ArgumentOutOfRangeException(nameof(startIndex), "The start index must be less than or equal to the array upper bound"); 35 | 36 | int i = 0; 37 | foreach (var item in source) 38 | { 39 | if (startIndex + i > upperBound) 40 | throw new ArgumentException("The array capacity is insufficient to copy all items from the source sequence"); 41 | array[startIndex + i] = item; 42 | i++; 43 | } 44 | } 45 | 46 | public static void AddRange(this ICollection collection, IEnumerable newItems) 47 | { 48 | foreach (T item in newItems) 49 | { 50 | collection.Add(item); 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Sigma.Core/Utils/LoggingUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using log4net; 11 | using log4net.Core; 12 | 13 | namespace Sigma.Core.Utils 14 | { 15 | /// 16 | /// A collection of utility methods for logging with . 17 | /// 18 | public static class LoggingUtils 19 | { 20 | /// 21 | /// Dynamically log a message to a certain level using a certain logger. 22 | /// 23 | /// The log level (fatal, error, warn, info, debug). 24 | /// The message to log. 25 | /// The logger to use. 26 | public static void Log(Level level, string message, ILog logger) 27 | { 28 | if (level.Value == Level.Fatal.Value) 29 | { 30 | logger.Fatal(message); 31 | } 32 | else if (level.Value == Level.Error.Value) 33 | { 34 | logger.Error(message); 35 | } 36 | else if (level.Value == Level.Warn.Value) 37 | { 38 | logger.Warn(message); 39 | } 40 | else if (level.Value == Level.Info.Value) 41 | { 42 | logger.Info(message); 43 | } 44 | else if (level.Value == Level.Debug.Value) 45 | { 46 | logger.Debug(message); 47 | } 48 | else 49 | { 50 | throw new ArgumentException($"Level {level} is not a supported logging level (supported levels are fatal, error, warn, info, debug)."); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Sigma.Core/Utils/ProcessUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using System.Diagnostics; 11 | using System.Runtime.InteropServices; 12 | 13 | namespace Sigma.Core.Utils 14 | { 15 | /// 16 | /// This utils-class provides the ability to check the process, OS. 17 | /// e.g. is 64 bit? 18 | /// 19 | public static class ProcessUtils 20 | { 21 | /// 22 | /// Determine whether the current application is running in 64bit mode. 23 | /// 24 | /// True if the process is started 64 bit, False otherwise. 25 | public static bool Is64BitProcess() 26 | { 27 | return IntPtr.Size == 8; 28 | } 29 | 30 | /// 31 | /// Determines whether the current OS is 64 bit or not. 32 | /// 33 | /// True if the OS is 64 bit, False otherwise. 34 | public static bool Is64BitOs() 35 | { 36 | return Is64BitProcess() || InternalCheckIsWow64(); 37 | } 38 | 39 | [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] 40 | [return: MarshalAs(UnmanagedType.Bool)] 41 | private static extern bool IsWow64Process 42 | ( 43 | [In] IntPtr hProcess, 44 | [Out] out bool wow64Process 45 | ); 46 | 47 | /// 48 | /// Check if a process is running in 64bit mode -> 64bit OS. 49 | /// 50 | /// True if any process runs in 64bit mode (and OS version is high enough). False otherwise. 51 | private static bool InternalCheckIsWow64() 52 | { 53 | if ((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1) || 54 | Environment.OSVersion.Version.Major >= 6) 55 | { 56 | using (Process p = Process.GetCurrentProcess()) 57 | { 58 | bool retVal; 59 | return IsWow64Process(p.Handle, out retVal) && retVal; 60 | } 61 | } 62 | return false; 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Sigma.Core/Utils/SigmaException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | 11 | namespace Sigma.Core.Utils 12 | { 13 | /// 14 | /// The general base class for all Sigma-specific exceptions. 15 | /// 16 | public class SigmaException : Exception 17 | { 18 | public SigmaException() 19 | { 20 | } 21 | 22 | public SigmaException(string message) : base(message) 23 | { 24 | } 25 | 26 | public SigmaException(string message, Exception innerException) : base(message, innerException) 27 | { 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sigma.Core/Utils/SystemInformationUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Diagnostics; 10 | 11 | namespace Sigma.Core.Utils 12 | { 13 | public static class SystemInformationUtils 14 | { 15 | public static long DefaultSystemMemoryAvailableBytes { get; set; } = 4L * 1024L * 1024L * 1024L; //4GB 16 | 17 | private static readonly PerformanceCounter MemoryCounterAvailableKBytes; 18 | 19 | static SystemInformationUtils() 20 | { 21 | MemoryCounterAvailableKBytes = new PerformanceCounter("Memory", "Available KBytes"); 22 | } 23 | 24 | public static long GetAvailablePhysicalMemoryBytes() 25 | { 26 | float readKBytes = MemoryCounterAvailableKBytes.NextValue(); 27 | long availableMemoryBytes = (long) readKBytes * 1024L; 28 | 29 | if (readKBytes <= 0) 30 | { 31 | availableMemoryBytes = DefaultSystemMemoryAvailableBytes; 32 | } 33 | 34 | return availableMemoryBytes; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Sigma.Core/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Sigma.Core/build/Sigma.Core.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %(RecursiveDir)%(FileName)%(Extension) 6 | Always 7 | 8 | 9 | %(RecursiveDir)%(FileName)%(Extension) 10 | Always 11 | 12 | 13 | %(RecursiveDir)%(FileName)%(Extension) 14 | Always 15 | 16 | 17 | %(RecursiveDir)%(FileName)%(Extension) 18 | Always 19 | 20 | 21 | %(RecursiveDir)%(FileName)%(Extension) 22 | Always 23 | 24 | 25 | %(RecursiveDir)%(FileName)%(Extension) 26 | Always 27 | 28 | 29 | -------------------------------------------------------------------------------- /Sigma.Core/libgcc_s_seh-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core/libgcc_s_seh-1.dll -------------------------------------------------------------------------------- /Sigma.Core/libgfortran-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core/libgfortran-3.dll -------------------------------------------------------------------------------- /Sigma.Core/libopenblas.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core/libopenblas.dll -------------------------------------------------------------------------------- /Sigma.Core/libopenblas.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core/libopenblas.so -------------------------------------------------------------------------------- /Sigma.Core/libquadmath-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Core/libquadmath-0.dll -------------------------------------------------------------------------------- /Sigma.Core/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Sigma.Kernels/Sigma.Kernels.licenseheader: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /Sigma.Samples/.gitignore: -------------------------------------------------------------------------------- 1 | libgcc_s_seh-1.dll 2 | libgfortran-3.dll 3 | libopenblas.dll 4 | libopenblas.so 5 | libquadmath-0.dll 6 | DiffSharp.dll -------------------------------------------------------------------------------- /Sigma.Samples/01-IRIS/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Sigma.Samples/01-IRIS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("01-IRIS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("01-IRIS")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e520248d-a792-4a03-a0ea-65369ab234ca")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Sigma.Samples/01-IRIS/Resources/Entypo-license.txt: -------------------------------------------------------------------------------- 1 | Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license. 2 | 3 | http://creativecommons.org/licenses/by-sa/3.0/ -------------------------------------------------------------------------------- /Sigma.Samples/01-IRIS/Resources/Entypo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Samples/01-IRIS/Resources/Entypo.ttf -------------------------------------------------------------------------------- /Sigma.Samples/01-IRIS/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Sigma.Samples/01-MNIST/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Sigma.Samples/01-MNIST/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("01-MNIST")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("01-MNIST")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c5938eef-0e15-4554-bc7f-fdbb164462ce")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Sigma.Samples/01-MNIST/Resources/Entypo-license.txt: -------------------------------------------------------------------------------- 1 | Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license. 2 | 3 | http://creativecommons.org/licenses/by-sa/3.0/ -------------------------------------------------------------------------------- /Sigma.Samples/01-MNIST/Resources/Entypo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Samples/01-MNIST/Resources/Entypo.ttf -------------------------------------------------------------------------------- /Sigma.Samples/01-MNIST/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Sigma.Samples/Sigma.Samples.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.4 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02-IRIS", "01-IRIS\02-IRIS.csproj", "{E520248D-A792-4A03-A0EA-65369AB234CA}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01-MNIST", "01-MNIST\01-MNIST.csproj", "{C5938EEF-0E15-4554-BC7F-FDBB164462CE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {E520248D-A792-4A03-A0EA-65369AB234CA}.Debug|x64.ActiveCfg = Debug|Any CPU 17 | {E520248D-A792-4A03-A0EA-65369AB234CA}.Debug|x64.Build.0 = Debug|Any CPU 18 | {E520248D-A792-4A03-A0EA-65369AB234CA}.Release|x64.ActiveCfg = Release|Any CPU 19 | {E520248D-A792-4A03-A0EA-65369AB234CA}.Release|x64.Build.0 = Release|Any CPU 20 | {C5938EEF-0E15-4554-BC7F-FDBB164462CE}.Debug|x64.ActiveCfg = Debug|x64 21 | {C5938EEF-0E15-4554-BC7F-FDBB164462CE}.Debug|x64.Build.0 = Debug|x64 22 | {C5938EEF-0E15-4554-BC7F-FDBB164462CE}.Release|x64.ActiveCfg = Release|x64 23 | {C5938EEF-0E15-4554-BC7F-FDBB164462CE}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Sigma.Tests.Internals.Backend/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: log4net.Config.XmlConfigurator(Watch = true)] 8 | [assembly: AssemblyTitle("Sigma.Tests.Internals.Backend")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Sigma.Tests.Internals.Backend")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("000f8da2-b16b-4b4a-8d0f-add3cacd2f2e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | 38 | -------------------------------------------------------------------------------- /Sigma.Tests.Internals.Backend/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Sigma.Tests.Internals.WPF/EmptyPanel.cs: -------------------------------------------------------------------------------- 1 | using Sigma.Core.Monitors.WPF.Panels; 2 | 3 | namespace Sigma.Tests.Internals.WPF 4 | { 5 | public class EmptyPanel : SigmaPanel 6 | { 7 | public EmptyPanel(string title) : base(title) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Sigma.Tests.Internals.WPF/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly: AssemblyTitle("Sigma.Tests.Internals.WPF")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Sigma.Tests.Internals.WPF")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | 25 | [assembly: Guid("5c4ed7ec-24d7-43ba-9424-cada167a3541")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | 38 | [assembly: AssemblyVersion("1.0.0.0")] 39 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /Sigma.Tests.Internals.WPF/Resources/Entypo-license.txt: -------------------------------------------------------------------------------- 1 | Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license. 2 | 3 | http://creativecommons.org/licenses/by-sa/3.0/ -------------------------------------------------------------------------------- /Sigma.Tests.Internals.WPF/Resources/Entypo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkingTransistor/Sigma/fd13fd974f72c76b3212c0fb85590927b62a7c2e/Sigma.Tests.Internals.WPF/Resources/Entypo.ttf -------------------------------------------------------------------------------- /Sigma.Tests.Internals.WPF/TestPanel.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using Sigma.Core.Monitors.WPF.Panels; 3 | 4 | namespace Sigma.Tests.Internals.WPF 5 | { 6 | public class TestPanel : GenericPanel 7 | { 8 | public TestPanel(string name, object content = null) : base(name, content) 9 | { 10 | Content = new StackPanel { Orientation = Orientation.Vertical }; 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Sigma.Tests/BaseLocaleTest.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Threading; 3 | using NUnit.Framework; 4 | 5 | namespace Sigma.Tests 6 | { 7 | public class BaseLocaleTest 8 | { 9 | private static readonly CultureInfo DefaultCultureInfo = new CultureInfo("en-GB"); 10 | 11 | [SetUp] 12 | public void SetUp() 13 | { 14 | SetDefaultCulture(DefaultCultureInfo); 15 | } 16 | 17 | private static void SetDefaultCulture(CultureInfo culture) 18 | { 19 | Thread.CurrentThread.CurrentCulture = culture; 20 | CultureInfo.DefaultThreadCurrentCulture = culture; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Sigma.Tests/Data/Preprocessors/TestNormalisingPreprocessor.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.Data.Preprocessors; 11 | using Sigma.Core.Handlers; 12 | using Sigma.Core.MathAbstract; 13 | using System; 14 | using System.Collections.Generic; 15 | using System.Linq; 16 | using Sigma.Core.Handlers.Backends.SigmaDiff.NativeCpu; 17 | using Sigma.Core.MathAbstract.Backends.SigmaDiff.NativeCpu; 18 | 19 | namespace Sigma.Tests.Data.Preprocessors 20 | { 21 | public class TestNormalisingPreprocessor 22 | { 23 | private static Dictionary GetNamedArrayTestData() 24 | { 25 | return new Dictionary() { ["test"] = new ADFloat32NDArray(-1L, new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 1, 1, 9)}; 26 | } 27 | 28 | [TestCase] 29 | public void TestNormalisingPreprocessorCreate() 30 | { 31 | Assert.Throws(() => new NormalisingPreprocessor(2, 1, "test")); 32 | Assert.Throws(() => new NormalisingPreprocessor(1, 2, 2, 1)); 33 | 34 | NormalisingPreprocessor normaliser = new NormalisingPreprocessor(1, 3, 0, 1, "test"); 35 | 36 | Assert.AreEqual(1, normaliser.MinInputValue); 37 | Assert.AreEqual(3, normaliser.MaxInputValue); 38 | Assert.AreEqual(0, normaliser.MinOutputValue); 39 | Assert.AreEqual(1, normaliser.MaxOutputValue); 40 | Assert.AreEqual(new[] { "test" }, normaliser.ProcessedSectionNames); 41 | } 42 | 43 | [TestCase] 44 | public void TestNormalisingPreprocessorExtractDirect() 45 | { 46 | NormalisingPreprocessor normaliser = new NormalisingPreprocessor(1, 9, 0, 1, "test"); 47 | IComputationHandler handler = new CpuFloat32Handler(); 48 | 49 | Dictionary extracted = normaliser.ExtractDirectFrom(GetNamedArrayTestData(), 1, handler); 50 | 51 | Assert.AreEqual(new[] { 0.0f, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f, 1.0f }, extracted["test"].GetDataAs().GetValuesArrayAs(0, 9).ToArray()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Sigma.Tests/Data/Preprocessors/TestOneHotPreprocessor.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.Data.Preprocessors; 11 | using Sigma.Core.Handlers; 12 | using Sigma.Core.MathAbstract; 13 | using System; 14 | using System.Collections.Generic; 15 | using System.Linq; 16 | using Sigma.Core.Handlers.Backends.SigmaDiff.NativeCpu; 17 | using Sigma.Core.MathAbstract.Backends.SigmaDiff; 18 | 19 | namespace Sigma.Tests.Data.Preprocessors 20 | { 21 | public class TestOneHotPreprocessor 22 | { 23 | private static Dictionary GetNamedArrayTestData() 24 | { 25 | return new Dictionary() { ["test"] = new ADNDArray(new float[] { 0, 2, 1 }, 3, 1, 1) }; 26 | } 27 | 28 | [TestCase] 29 | public void TestOneHotPreprocessorCreate() 30 | { 31 | Assert.Throws(() => new OneHotPreprocessor(sectionName: "section")); 32 | 33 | OneHotPreprocessor preprocessor = new OneHotPreprocessor("section", 1, 2, 3, 4); 34 | 35 | Assert.AreEqual(new[] { "section" }, preprocessor.ProcessedSectionNames); 36 | } 37 | 38 | [TestCase] 39 | public void TestOneHotPreprocessorExtract() 40 | { 41 | OneHotPreprocessor preprocessor = new OneHotPreprocessor("test", minValue: 0, maxValue: 2); 42 | IComputationHandler handler = new CpuFloat32Handler(); 43 | 44 | Dictionary extracted = preprocessor.ExtractDirectFrom(GetNamedArrayTestData(), 2, handler); 45 | 46 | Assert.AreEqual(new float[] { 1, 0, 0, 0, 0, 1 }, extracted["test"].GetDataAs().GetValuesArrayAs(0, 6).ToArray()); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Sigma.Tests/Data/Sources/TestFileSource.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.Data.Sources; 11 | using System; 12 | using System.IO; 13 | 14 | namespace Sigma.Tests.Data.Sources 15 | { 16 | public class TestFileSource 17 | { 18 | [TestCase] 19 | public void TestFileSourceCheckNonExisting() 20 | { 21 | FileSource source = new FileSource("thisfiledoesntexistdoesit"); 22 | 23 | Assert.IsFalse(source.Exists()); 24 | } 25 | 26 | [TestCase] 27 | public void TestFileSourceAccessNonExisting() 28 | { 29 | FileSource source = new FileSource("thisfiledoesntexistdoesit"); 30 | 31 | Assert.Throws(() => source.Prepare()); 32 | 33 | Assert.Throws(() => source.Retrieve()); 34 | } 35 | 36 | [TestCase] 37 | public void TestFileSourceCheckExisting() 38 | { 39 | String fileFolder = Path.GetTempPath(); 40 | String fileName = ".unittestfile1"; 41 | 42 | File.Create(fileFolder + "/" + fileName).Dispose(); 43 | 44 | FileSource source = new FileSource(".unittestfile1", fileFolder); 45 | 46 | Assert.IsTrue(source.Exists()); 47 | 48 | File.Delete(fileFolder + "/" + fileName); 49 | } 50 | 51 | [TestCase] 52 | public void TestFileSourceAccessExisting() 53 | { 54 | String fileFolder = Path.GetTempPath(); 55 | String fileName = ".unittestfile2"; 56 | 57 | File.Create(fileFolder + "/" + fileName).Dispose(); 58 | 59 | FileSource source = new FileSource(".unittestfile2", fileFolder); 60 | 61 | Assert.Throws(() => source.Retrieve()); 62 | 63 | source.Prepare(); 64 | 65 | Stream stream = source.Retrieve(); 66 | 67 | Assert.IsNotNull(stream); 68 | 69 | stream.Dispose(); 70 | 71 | File.Delete(fileFolder + "/" + fileName); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Sigma.Tests/Layers/MockLayer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using Sigma.Core.Architecture; 10 | using Sigma.Core.Handlers; 11 | using Sigma.Core.Layers; 12 | using Sigma.Core.Utils; 13 | 14 | namespace Sigma.Tests.Layers 15 | { 16 | public class MockLayer : BaseLayer 17 | { 18 | public MockLayer(string name, IRegistry parameters, IComputationHandler handler) : base(name, parameters, handler) 19 | { 20 | } 21 | 22 | public override void Run(ILayerBuffer buffer, IComputationHandler handler, bool trainingPass) 23 | { 24 | } 25 | 26 | public static LayerConstruct Construct() 27 | { 28 | return new LayerConstruct("#-mocktestlayer", typeof(MockLayer)); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Sigma.Tests/Math/TestNumber.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.MathAbstract.Backends.SigmaDiff; 11 | 12 | namespace Sigma.Tests.Math 13 | { 14 | public class TestNumber 15 | { 16 | [TestCase] 17 | public void TestNumberGetSet() 18 | { 19 | ADNumber adNumber = new ADNumber(0.3f); 20 | 21 | Assert.AreEqual(0.3f, adNumber.Value); 22 | 23 | adNumber.Value = 0.2f; 24 | 25 | Assert.AreEqual(0.2f, adNumber.Value); 26 | 27 | Assert.That(() => adNumber.Value = null, Throws.Exception); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sigma.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System.Reflection; 10 | using System.Runtime.InteropServices; 11 | 12 | // General Information about an assembly is controlled through the following 13 | // set of attributes. Change these attribute values to modify the information 14 | // associated with an assembly. 15 | [assembly: AssemblyTitle("Sigma.Tests")] 16 | [assembly: AssemblyDescription("")] 17 | [assembly: AssemblyConfiguration("")] 18 | [assembly: AssemblyCompany("")] 19 | [assembly: AssemblyProduct("Sigma.Tests")] 20 | [assembly: AssemblyCopyright("Copyright © 2016")] 21 | [assembly: AssemblyTrademark("")] 22 | [assembly: AssemblyCulture("")] 23 | 24 | // Setting ComVisible to false makes the types in this assembly not visible 25 | // to COM components. If you need to access a type in this assembly from 26 | // COM, set the ComVisible attribute to true on that type. 27 | [assembly: ComVisible(false)] 28 | 29 | // The following GUID is for the ID of the typelib if this project is exposed to COM 30 | [assembly: Guid("656f0373-6309-409b-be43-9bec8b0840ac")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] 44 | -------------------------------------------------------------------------------- /Sigma.Tests/Sigma.Tests.licenseheader: -------------------------------------------------------------------------------- 1 | extensions: .cs 2 | /* 3 | MIT License 4 | 5 | Copyright (c) 2016-%CurrentYear% Florian Cäsar, Michael Plainer 6 | 7 | For full license see LICENSE in the root directory of this project. 8 | */ 9 | -------------------------------------------------------------------------------- /Sigma.Tests/TestCUDAInstallation.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using ManagedCuda; 10 | using ManagedCuda.CudaBlas; 11 | using NUnit.Framework; 12 | 13 | namespace Sigma.Tests 14 | { 15 | public class TestCudaInstallation 16 | { 17 | private static bool _cudaInstalled; 18 | private static bool _checkedCudaInstalled; 19 | 20 | public static void AssertIgnoreIfCudaUnavailable() 21 | { 22 | if (!_checkedCudaInstalled) 23 | { 24 | try 25 | { 26 | new CudaContext(); 27 | 28 | _cudaInstalled = true; 29 | } 30 | catch 31 | { 32 | _cudaInstalled = false; 33 | } 34 | 35 | _checkedCudaInstalled = true; 36 | } 37 | 38 | if (!_cudaInstalled) 39 | { 40 | Assert.Ignore("CUDA installation not found or not working. As CUDA is optional, this test will be ignored."); 41 | } 42 | } 43 | 44 | [TestCase] 45 | public void TestCudaInstallationCreateContext() 46 | { 47 | AssertIgnoreIfCudaUnavailable(); 48 | 49 | CudaContext context = new CudaContext(); 50 | } 51 | 52 | [TestCase] 53 | public void TestCudaInstallationCreateCudaBlas() 54 | { 55 | AssertIgnoreIfCudaUnavailable(); 56 | 57 | CudaBlas cublas = new CudaBlas(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Sigma.Tests/TestSigmaEnvironment.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core; 11 | using System; 12 | 13 | namespace Sigma.Tests 14 | { 15 | internal class TestSigmaEnvironment 16 | { 17 | [TestCase] 18 | public void TestSigmaEnvironmentCreate() 19 | { 20 | SigmaEnvironment.Clear(); 21 | 22 | SigmaEnvironment sigma = SigmaEnvironment.Create("test"); 23 | 24 | Assert.AreEqual("test", sigma.Name); 25 | } 26 | 27 | [TestCase] 28 | public void TestSigmaEnvironmentAlreadyCreated() 29 | { 30 | SigmaEnvironment.Clear(); 31 | 32 | SigmaEnvironment.Create("test"); 33 | 34 | Assert.Throws(() => SigmaEnvironment.Create("test")); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Sigma.Tests/Training/Initialisers/TestConstantValueInitialiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.Handlers; 11 | using Sigma.Core.MathAbstract; 12 | using Sigma.Core.Training.Initialisers; 13 | using System; 14 | using Sigma.Core.Handlers.Backends.SigmaDiff.NativeCpu; 15 | using Sigma.Core.MathAbstract.Backends.SigmaDiff; 16 | using Sigma.Core.MathAbstract.Backends.SigmaDiff.NativeCpu; 17 | 18 | namespace Sigma.Tests.Training.Initialisers 19 | { 20 | public class TestConstantValueInitialiser 21 | { 22 | [TestCase] 23 | public void TestConstantValueInitialiserInitialise() 24 | { 25 | ConstantValueInitialiser initialiser = new ConstantValueInitialiser(2.0); 26 | 27 | IComputationHandler handler = new CpuFloat32Handler(); 28 | INDArray array = handler.NDArray(2L, 1L, 2L, 2L); 29 | 30 | Random random = new Random(); 31 | 32 | Assert.Throws(() => initialiser.Initialise((INDArray) null, handler, random)); 33 | Assert.Throws(() => initialiser.Initialise((INumber) null, handler, random)); 34 | Assert.Throws(() => initialiser.Initialise(array, null, random)); 35 | Assert.Throws(() => initialiser.Initialise(array, handler, null)); 36 | 37 | initialiser.Initialise(array, handler, new Random()); 38 | 39 | Assert.AreEqual(new float[] { 2, 2, 2, 2, 2, 2, 2, 2 }, array.GetDataAs().GetValuesArrayAs(0, 8)); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Sigma.Tests/Training/Initialisers/TestCustomInitialiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using System; 10 | using NUnit.Framework; 11 | using Sigma.Core.Handlers.Backends.SigmaDiff.NativeCpu; 12 | using Sigma.Core.MathAbstract.Backends.SigmaDiff; 13 | using Sigma.Core.Training.Initialisers; 14 | 15 | namespace Sigma.Tests.Training.Initialisers 16 | { 17 | public class TestCustomInitialiser 18 | { 19 | [TestCase] 20 | public void TestCustomInitialiserCreate() 21 | { 22 | Assert.Throws(() => new CustomInitialiser(null)); 23 | } 24 | 25 | [TestCase] 26 | public void TestCustomInitialiserInitialise() 27 | { 28 | CustomInitialiser initialiser = new CustomInitialiser((i, s, r) => 5); 29 | 30 | ADNDArray array = new ADNDArray(2, 3); 31 | 32 | initialiser.Initialise(array, new CpuFloat32Handler(), new Random()); 33 | 34 | foreach (var value in array.GetDataAs()) 35 | { 36 | Assert.AreEqual(5, value); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Sigma.Tests/Training/Initialisers/TestGaussianInitialiser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.Handlers; 11 | using Sigma.Core.MathAbstract; 12 | using Sigma.Core.Training.Initialisers; 13 | using System; 14 | using Sigma.Core.Handlers.Backends.SigmaDiff.NativeCpu; 15 | using Sigma.Core.MathAbstract.Backends.SigmaDiff; 16 | 17 | namespace Sigma.Tests.Training.Initialisers 18 | { 19 | public class TestGaussianInitialiser 20 | { 21 | [TestCase] 22 | public void TestGaussianInitialiserInitialise() 23 | { 24 | ConstantValueInitialiser initialiser = new ConstantValueInitialiser(2.0); 25 | 26 | INDArray array = new ADNDArray(2, 1, 2, 2); 27 | IComputationHandler handler = new CpuFloat32Handler(); 28 | Random random = new Random(); 29 | 30 | Assert.Throws(() => initialiser.Initialise((INDArray) null, handler, random)); 31 | Assert.Throws(() => initialiser.Initialise((INumber) null, handler, random)); 32 | Assert.Throws(() => initialiser.Initialise(array, null, random)); 33 | Assert.Throws(() => initialiser.Initialise(array, handler, null)); 34 | 35 | // TODO implement gaussian initialiser test somehow 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Sigma.Tests/Training/Mergers/NetworkMergerTestUtils.cs: -------------------------------------------------------------------------------- 1 | using Sigma.Core; 2 | using Sigma.Core.Architecture; 3 | using Sigma.Core.Handlers.Backends.SigmaDiff.NativeCpu; 4 | using Sigma.Core.Layers; 5 | using Sigma.Core.Layers.External; 6 | using Sigma.Core.Layers.Feedforward; 7 | using Sigma.Core.Training; 8 | using Sigma.Core.Training.Initialisers; 9 | using Sigma.Core.Training.Operators.Backends.NativeCpu; 10 | 11 | namespace Sigma.Tests.Training.Mergers 12 | { 13 | public class NetworkMergerTestUtils 14 | { 15 | private static SigmaEnvironment _environment; 16 | private static int _count; 17 | 18 | public static INetwork GenerateNetwork(double number) 19 | { 20 | if (_environment == null) 21 | { 22 | _environment = SigmaEnvironment.Create("TestAverageNetworkMergerEnvironment"); 23 | } 24 | 25 | ITrainer trainer = _environment.CreateTrainer($"trainer{_count++}"); 26 | 27 | Network net = new Network(); 28 | net.Architecture = InputLayer.Construct(2, 2) + FullyConnectedLayer.Construct(2 * 2) + OutputLayer.Construct(2); 29 | 30 | trainer.Network = net; 31 | trainer.AddInitialiser("*.weights", new ConstantValueInitialiser(number)); 32 | 33 | trainer.Operator = new CpuSinglethreadedOperator(); 34 | 35 | trainer.Initialise(new CpuFloat32Handler()); 36 | 37 | SigmaEnvironment.Clear(); 38 | 39 | return net; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Sigma.Tests/Training/Mergers/TestAverageNetworkMerger.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using NUnit.Framework; 3 | using Sigma.Core; 4 | using Sigma.Core.Architecture; 5 | using Sigma.Core.Handlers.Backends.SigmaDiff.NativeCpu; 6 | using Sigma.Core.Layers; 7 | using Sigma.Core.Layers.Feedforward; 8 | using Sigma.Core.MathAbstract; 9 | using Sigma.Core.Training; 10 | using Sigma.Core.Training.Initialisers; 11 | using Sigma.Core.Training.Mergers; 12 | using Sigma.Core.Training.Operators.Backends.NativeCpu; 13 | using Sigma.Core.Utils; 14 | 15 | namespace Sigma.Tests.Training.Mergers 16 | { 17 | public class TestAverageNetworkMerger 18 | { 19 | [TestCase] 20 | public void TestAverageNetworkMergerMerge() 21 | { 22 | INetworkMerger merger = new AverageNetworkMerger(); 23 | INetwork netA = NetworkMergerTestUtils.GenerateNetwork(1); 24 | INetwork netB = NetworkMergerTestUtils.GenerateNetwork(5); 25 | 26 | merger.AddMergeEntry("layers.*.weights"); 27 | 28 | merger.Merge(netA, netB); 29 | 30 | IRegistryResolver resolverA = new RegistryResolver(netA.Registry); 31 | IRegistryResolver resolverB = new RegistryResolver(netB.Registry); 32 | 33 | INDArray weightsA = resolverA.ResolveGet("layers.*.weights")[0]; 34 | INDArray weightsB = resolverB.ResolveGet("layers.*.weights")[0]; 35 | 36 | float firstValueA = weightsA.GetValue(0, 0); 37 | float firstValueB = weightsB.GetValue(0, 0); 38 | 39 | // the first value will change 40 | Assert.AreEqual(3, firstValueA); 41 | 42 | // the second net may not be changed 43 | Assert.AreEqual(5, firstValueB); 44 | 45 | merger.RemoveMergeEntry("layers.*.weights"); 46 | 47 | merger.Merge(netA, netB); 48 | weightsA = resolverA.ResolveGet("layers.*.weights")[0]; 49 | firstValueA = weightsA.GetValue(0, 0); 50 | 51 | Assert.AreEqual(3, firstValueA); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Sigma.Tests/Training/Mergers/TestWeightedNetworkMerger.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using Sigma.Core.Architecture; 3 | using Sigma.Core.MathAbstract; 4 | using Sigma.Core.Training.Mergers; 5 | using Sigma.Core.Utils; 6 | 7 | namespace Sigma.Tests.Training.Mergers 8 | { 9 | public class TestWeightedNetworkMerger 10 | { 11 | [TestCase] 12 | public void TestWeightedNetworkMergerMerge() 13 | { 14 | INetworkMerger merger = new WeightedNetworkMerger(3, 8); 15 | INetwork netA = NetworkMergerTestUtils.GenerateNetwork(1); 16 | INetwork netB = NetworkMergerTestUtils.GenerateNetwork(9); 17 | 18 | merger.AddMergeEntry("layers.*.weights"); 19 | 20 | merger.Merge(netA, netB); 21 | 22 | IRegistryResolver resolverA = new RegistryResolver(netA.Registry); 23 | IRegistryResolver resolverB = new RegistryResolver(netB.Registry); 24 | 25 | INDArray weightsA = resolverA.ResolveGet("layers.*.weights")[0]; 26 | INDArray weightsB = resolverB.ResolveGet("layers.*.weights")[0]; 27 | 28 | float firstValueA = weightsA.GetValue(0, 0); 29 | float firstValueB = weightsB.GetValue(0, 0); 30 | 31 | // the first value will change 32 | Assert.AreEqual(6.82, System.Math.Round(firstValueA * 100) / 100); 33 | 34 | // the second net may not be changed 35 | Assert.AreEqual(9, firstValueB); 36 | 37 | merger.RemoveMergeEntry("layers.*.weights"); 38 | 39 | merger.Merge(netA, netB); 40 | weightsA = resolverA.ResolveGet("layers.*.weights")[0]; 41 | firstValueA = weightsA.GetValue(0, 0); 42 | 43 | // may not change 44 | Assert.AreEqual(6.82, System.Math.Round(firstValueA * 100) / 100); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Sigma.Tests/Utils/TestArrayUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.Utils; 11 | 12 | namespace Sigma.Tests.Utils 13 | { 14 | public class TestArrayUtils 15 | { 16 | [TestCase] 17 | public void TestArrayUtilsProduct() 18 | { 19 | Assert.AreEqual(120L, ArrayUtils.Product(2, 3, 4, 5)); 20 | Assert.AreEqual(-1800L, ArrayUtils.Product(2, 3, 4, 5, -15)); 21 | } 22 | 23 | [TestCase] 24 | public void TestArrayUtilsRange() 25 | { 26 | Assert.AreEqual(new[] { 2, 3, 4, 5 }, ArrayUtils.Range(2, 5, 1)); 27 | Assert.AreEqual(new[] { 10, 9, 8, 7 }, ArrayUtils.Range(10, 7, 1)); 28 | 29 | Assert.AreEqual(new[] { 2, 4 }, ArrayUtils.Range(2, 5, 2)); 30 | Assert.AreEqual(new[] { 5, 3 }, ArrayUtils.Range(5, 2, 2)); 31 | 32 | Assert.Throws(() => ArrayUtils.Range(1, 2, -1)); 33 | } 34 | 35 | [TestCase] 36 | public void TestArrayUtilsPermuteArray() 37 | { 38 | Assert.AreEqual(new long[] { 4, 2, 1, 3 }, ArrayUtils.PermuteArray(new long[] { 1, 2, 3, 4 }, new[] { 3, 1, 0, 2 })); 39 | } 40 | 41 | [TestCase] 42 | public void TestArrayUtilsGetFlatColumnMappings() 43 | { 44 | Assert.AreEqual(new[] { 1, 2, 3, 4, 5, 9 }, ArrayUtils.GetFlatColumnMappings(new[] { new[] { 1, 5 }, new[] { 9 } })); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Sigma.Tests/Utils/TestDiskCacheProvider.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.Utils; 11 | using System; 12 | using System.IO; 13 | 14 | namespace Sigma.Tests.Utils 15 | { 16 | public class TestDiskCacheProvider 17 | { 18 | [TestCase] 19 | public void TestDiskCacheProviderCreate() 20 | { 21 | Assert.Throws(() => new DiskCacheProvider(null)); 22 | 23 | DiskCacheProvider provider = new DiskCacheProvider(Path.GetTempPath()); 24 | 25 | Assert.AreEqual(Path.GetTempPath(), provider.RootDirectory); 26 | } 27 | 28 | [TestCase] 29 | public void TestDiskCacheProviderStore() 30 | { 31 | DiskCacheProvider provider = new DiskCacheProvider(Path.GetTempPath() + nameof(TestDiskCacheProviderStore)); 32 | 33 | provider.Store("test", "hellofriend"); 34 | provider.Store("tost", "hallofreund"); 35 | 36 | Assert.IsTrue(provider.IsCached("test")); 37 | Assert.IsTrue(provider.IsCached("tost")); 38 | } 39 | 40 | [TestCase] 41 | public void TestDiskCacheProviderLoad() 42 | { 43 | DiskCacheProvider provider = new DiskCacheProvider(Path.GetTempPath() + nameof(TestDiskCacheProviderLoad)); 44 | 45 | provider.Store("test", "hellofriend"); 46 | provider.Store("tost", "hallofreund"); 47 | 48 | Assert.AreEqual("hellofriend", provider.Load("test")); 49 | Assert.AreEqual("hallofreund", provider.Load("tost")); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Sigma.Tests/Utils/TestTaskObserver.cs: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2016-2017 Florian Cäsar, Michael Plainer 5 | 6 | For full license see LICENSE in the root directory of this project. 7 | */ 8 | 9 | using NUnit.Framework; 10 | using Sigma.Core.Utils; 11 | using System; 12 | 13 | namespace Sigma.Tests.Utils 14 | { 15 | public class TestTaskObserver 16 | { 17 | [TestCase] 18 | public void TestTaskObserverCreate() 19 | { 20 | Assert.Throws(() => new TaskObserver(null)); 21 | 22 | TaskObserver observer = new TaskObserver(TaskType.Prepare, "description", false); 23 | 24 | Assert.AreSame(TaskType.Prepare, observer.Type); 25 | Assert.AreEqual("description", observer.Description); 26 | Assert.IsFalse(observer.Exposed); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Sigma.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Sigma.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | --------------------------------------------------------------------------------