Exemple #1
0
        private List <List <String> > parseRows(String source, Action <CsvStreamToRowProcessor> callback = null)
        {
            StreamInformation       si         = new StreamInformation(new Settings());
            CsvStreamToRowProcessor csvProcess = new CsvStreamToRowProcessor();

            StringStreamFactory wrapper = new StringStreamFactory(source);

            csvProcess.setSource(si, wrapper);

            CaptureRowProcessor capture = new CaptureRowProcessor();

            csvProcess.setNextRowProcessor(capture);

            if (callback != null)
            {
                callback(csvProcess);
            }

            try
            {
                csvProcess.process();
                return(capture.rows);
            }
            finally
            {
                try { wrapper.Dispose(); } catch (Exception) { }
                try { csvProcess.Dispose(); } catch (Exception) { }
            }
        }
        private String validateNewline(String newline)
        {
            if (String.IsNullOrEmpty(newline))
            {
                throw new InvalidArgumentException("Default newline setting must have a value");
            }

            if (NEWLINE_EXPRESSION.IsMatch(newline))
            {
                return(newline);
            }

            // Converts 'named' strings into newlines
            IDictionary <String, NewLineEnum> named = EnumUtil.toDictionary <NewLineEnum>();

            if (named.ContainsKey(newline))
            {
                NewLineEnum newlineType = named[newline];
                if (newlineType != NewLineEnum.None)
                {
                    return(StreamInformation.newlineString(newlineType));
                }
            }

            throw new InvalidArgumentException("Unrecognized newline '{0}'", newline);
        }
Exemple #3
0
        // pnyx -e=documentation pncs.cmd.examples.documentation.library.ExampleProcessorChain processorChain
        public static void processorChain()
        {
            StreamInformation streamInformation = new StreamInformation(new Settings());

            // Writes to STDOUT
            ILineProcessor dest = new LineProcessorToStream(streamInformation, Console.OpenStandardOutput());

            // Grep filter / processor pair
            ILineFilter grepFilter = new Grep {
                textToFind = "world", caseSensitive = false
            };
            ILineProcessor grepProcessor = new LineFilterProcessor {
                filter = grepFilter, processor = dest
            };

            // Sed transformer / processor pair
            ILineTransformer sedTransformer = new SedReplace("World", "World, with love from Pnyx..", null);
            ILineProcessor   sedProcessor   = new LineTransformerProcessor {
                transform = sedTransformer, processor = grepProcessor
            };

            // Reads from source
            using (StringStreamFactory streamFactory = new StringStreamFactory("Hello World."))
            {
                using (StreamToLineProcessor source = new StreamToLineProcessor(streamInformation, streamFactory))
                {
                    source.setNextLineProcessor(sedProcessor);

                    // Runs
                    source.process();                // All I/O occurs on this step
                }
            }

            // outputs: Hello World, with love from Pnyx...
        }
 public LineProcessorSplit(StreamInformation streamInformation, String fileNamePattern, int limit, String path)
 {
     this.streamInformation = streamInformation;
     this.fileNamePattern   = fileNamePattern;
     this.limit             = limit;
     this.path = path;
 }
Exemple #5
0
        /// <summary>
        /// Get the list of data streams for the given handle.
        /// </summary>
        public unsafe static IEnumerable <StreamInformation> GetStreamInformation(SafeFileHandle fileHandle)
        {
            return(BufferHelper.BufferInvoke((HeapBuffer buffer) =>
            {
                unsafe
                {
                    while (!Imports.GetFileInformationByHandleEx(fileHandle, FileInfoClass.FileStreamInfo,
                                                                 buffer.VoidPointer, checked ((uint)buffer.ByteCapacity)))
                    {
                        WindowsError error = Errors.GetLastError();
                        switch (error)
                        {
                        case WindowsError.ERROR_HANDLE_EOF:
                            // No streams
                            return Enumerable.Empty <StreamInformation>();

                        case WindowsError.ERROR_MORE_DATA:
                            buffer.EnsureByteCapacity(buffer.ByteCapacity * 2);
                            break;

                        default:
                            throw Errors.GetIoExceptionForError(error);
                        }
                    }
                }

                return StreamInformation.Create((FILE_STREAM_INFORMATION *)buffer.VoidPointer);
            }));
        }
        private void HandleFlushSuccessful(WriteState item, long currentPos)
        {
            switch (item.State)
            {
            case EventState.Event:
            case EventState.Snapshot:
                idToPos.AddOrUpdate(item.Id, s => new StreamInformation
                {
                    LastPosition = currentPos,
                    StreamLength = 1
                }, (s, l) => new StreamInformation
                {
                    LastPosition = currentPos,
                    StreamLength = l.StreamLength + 1
                });
                break;

            case EventState.Delete:
                var streamInformation = new StreamInformation
                {
                    LastPosition = Deleted,
                    StreamLength = 0
                };
                idToPos.AddOrUpdate(item.Id, s => streamInformation, (s, l) =>
                {
                    deleteCount += l.StreamLength;
                    return(streamInformation);
                });
                break;

            default:
                throw new ArgumentOutOfRangeException(item.State.ToString());
            }
            item.TaskCompletionSource.SetResult(null);
        }
        /// <summary>
        /// The method is called during training process. The method returns the chunk of data specified by Batch size.
        /// </summary>
        /// <param name="minibatchSizeInSamples"></param>
        /// <param name="device"></param>
        /// <returns></returns>
        public UnorderedMapStreamInformationMinibatchData GetNextMinibatch(uint minibatchSizeInSamples, DeviceDescriptor device)
        {
            if (Type == MinibatchType.Default || Type == MinibatchType.Image)
            {
                var retVal = defaultmb.GetNextMinibatch(minibatchSizeInSamples, device);
                return(retVal);
            }
            else if (Type == MinibatchType.Custom)
            {
                var retVal = nextBatch(custommb, StreamConfigurations, (int)minibatchSizeInSamples);
                var mb     = new UnorderedMapStreamInformationMinibatchData();
                var eofs   = custommb.EndOfStream;
                //create minibatch
                foreach (var d in retVal)
                {
                    var v   = Value.CreateBatchOfSequences <float>(new NDShape(1, d.Key.m_dim), d.Value, device);
                    var mbd = new MinibatchData(v, (uint)d.Value.Count(), (uint)d.Value.Sum(x => x.Count), eofs);

                    var si = new StreamInformation();
                    si.m_definesMbSize = d.Key.m_definesMbSize;
                    si.m_storageFormat = StorageFormat.Dense;
                    si.m_name          = d.Key.m_streamName;

                    mb.Add(si, mbd);
                }

                return(mb);
            }
            else
            {
                throw new Exception("Unsupported Mini-batch-source type!");
            }
        }
Exemple #8
0
        /// <summary>
        /// The method is called during training process. The method returns the chunk of data specified by Batch size.
        /// </summary>
        /// <param name="minibatchSizeInSamples"></param>
        /// <param name="device"></param>
        /// <returns></returns>
        public UnorderedMapStreamInformationMinibatchData GetNextMinibatch(uint minibatchSizeInSamples, DeviceDescriptor device)
        {
            if (Type == MinibatchType.Default)
            {
                var retVal = defaultmb.GetNextMinibatch(minibatchSizeInSamples, device);
                return(retVal);
            }
            else if (Type == MinibatchType.Custom)
            {
                var retVal = nextBatch(custommb, StreamConfigurations, (int)minibatchSizeInSamples, 1, device);
                var mb     = new UnorderedMapStreamInformationMinibatchData();

                for (int i = 0; i < retVal.Count; i++)
                {
                    var k = retVal.ElementAt(i);
                    //this is fix for 2.6 version since the Value  data is not valid, so it must be clone in order to create MiniBatchData
                    // var mbData = new MinibatchData(k.Value.data.DeepClone(), k.Value.numberOfSequences, k.Value.numberOfSamples, k.Value.sweepEnd);

                    var si = new StreamInformation();
                    si.m_definesMbSize = StreamConfigurations[i].m_definesMbSize;
                    si.m_storageFormat = k.Value.data.StorageFormat;
                    si.m_name          = StreamConfigurations[i].m_streamName;

                    //
                    //mb.Add(si, mbData);
                    mb.Add(si, k.Value);
                }

                return(mb);
            }
            else
            {
                throw new Exception("Unsupported Mini-batch-source type!");
            }
        }
        private async Task OnTick()
        {
            try
            {
                StreamInformation info = await main.GetStreamInformation();

                ViewerCountValue.Text = info.viewers.ToString();
                InfoTextBlock.Text    = @"Name: " + info.channel.display_name + Environment.NewLine;
                InfoTextBlock.Text   += @"Game: " + info.game + Environment.NewLine;
                InfoTextBlock.Text   += @"Status: " + info.channel.status + Environment.NewLine;
                InfoTextBlock.Text   += @"Language: " + info.channel.language + Environment.NewLine;
                InfoTextBlock.Text   += @"Video height: " + info.video_height + Environment.NewLine;
                InfoTextBlock.Text   += @"Average fps: " + info.average_fps + Environment.NewLine;
                InfoTextBlock.Text   += @"Started at: " + info.created_at + Environment.NewLine;
                InfoTextBlock.Text   += @"Views: " + info.channel.views + Environment.NewLine;
                InfoTextBlock.Text   += @"Followers: " + info.channel.followers + Environment.NewLine;
                InfoTextBlock.Text   += @"URL: " + info.channel.url + Environment.NewLine;

                LastUpdated.Text = DateTime.Now.ToString(CultureInfo.CurrentCulture.DateTimeFormat);

                var chatters = await main.GetStreamChatters(StreamerTextBox.Text.ToLower());

                ViewersTextBlock.Text = chatters;
            }
            catch
            {
                ErrorTextBlock.Text = "Couldn't fetch stream info";
            }
        }
        protected override void PrepareTrainingData(ITrainingDatasetDefinition datasetDefinition)
        {
            _minibatchSource = MinibatchSource.TextFormatMinibatchSource(
                TrainingDataset.TrainingDatasetPath, GetStreamConfigFrom(datasetDefinition), MinibatchSource.InfinitelyRepeat);

            _featureStreamInfo = _minibatchSource.StreamInfo(FeatureStreamName);
            _labelStreamInfo   = _minibatchSource.StreamInfo(LabelsStreamName);
        }
Exemple #11
0
        public IProcessor buildProcessor(StreamInformation streamInformation, IStreamFactory streamFactory)
        {
            CsvStreamToRowProcessor result = new CsvStreamToRowProcessor(settings);

            result.hasHeader = hasHeader;
            result.setSource(streamInformation, streamFactory);
            return(result);
        }
Exemple #12
0
 public PreparedDataInfo(string preparedDataPath, string featureStreamName,
                         string labelsStreamName, int imageSize, int numClasses, ulong epochSize)
 {
     MinibatchSource = GetMinibatchSource(preparedDataPath, featureStreamName, labelsStreamName, imageSize,
                                          numClasses, epochSize);
     FeatureStreamInfo = MinibatchSource.StreamInfo(featureStreamName);
     LabelStreamInfo   = MinibatchSource.StreamInfo(labelsStreamName);
 }
Exemple #13
0
        private void ShowSelectionAudioMessage(StackPanel contentPanel)
        {
            try
            {
                //재생패널 닫기 요청
                if (isPlayerOpened)
                {
                    MessengerInstance.Send(new Message("ExitPlay", true), CCPlayerViewModel.NAME);
                }

                //로딩 패널 제거
                if (LoadingPanelVisible)
                {
                    OnShowLoadingPanel(new KeyValuePair <string, bool>(string.Empty, false));
                }

                if (App.ContentDlgOp != null)
                {
                    return;
                }

                ContentDialog contentDlg = new ContentDialog
                {
                    Content           = contentPanel,
                    PrimaryButtonText = ResourceLoader.GetForCurrentView().GetString("OK")
                };
                //메세지 창 출력
                App.ContentDlgOp = contentDlg.ShowAsync();
                //후처리기 등록
                App.ContentDlgOp.Completed = new AsyncOperationCompletedHandler <ContentDialogResult>((op, status) =>
                {
                    App.ContentDlgOp             = null;
                    StreamInformation streamInfo = null;

                    foreach (StackPanel panel in contentPanel.Children.Where(x => x is StackPanel))
                    {
                        if (panel != null)
                        {
                            RadioButton rb = panel.Children.FirstOrDefault(x => x is RadioButton) as RadioButton;
                            if (rb != null && rb.IsChecked == true)
                            {
                                streamInfo = rb.Tag as StreamInformation;
                                break;
                            }
                        }
                    }

                    if (streamInfo != null)
                    {
                        MessengerInstance.Send(new Message("MultiAudioSelecting", streamInfo), CCPlayerViewModel.NAME);
                    }
                });
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.StackTrace);
            }
        }
        public static float ValidateModelWithMinibatchSource(string modelFile, MinibatchSource testMinibatchSource, int[] imageDim, int numClasses, string featureInputName, string labelInputName, string outputName, DeviceDescriptor device, int maxCount = 1000)
        {
            Function model       = Function.Load(modelFile, device);
            Variable imageInput  = model.Arguments[0];
            Variable labelOutput = model.Outputs.Single(o => o.Name == outputName);

            StreamInformation featureStreamInfo = testMinibatchSource.StreamInfo(featureInputName);
            StreamInformation labelStreamInfo   = testMinibatchSource.StreamInfo(labelInputName);

            int batchSize = 50;
            int miscountTotal = 0, totalCount = 0;

            while (true)
            {
                UnorderedMapStreamInformationMinibatchData minibatchData = testMinibatchSource.GetNextMinibatch((uint)batchSize, device);
                if (minibatchData == null || minibatchData.Count == 0)
                {
                    break;
                }

                totalCount += (int)minibatchData[featureStreamInfo].numberOfSamples;

                // Expected labels are in the minibatch data.
                IList <IList <float> > labelData      = minibatchData[labelStreamInfo].data.GetDenseData <float>(labelOutput);
                List <int>             expectedLabels = labelData.Select(l => l.IndexOf(l.Max())).ToList();

                Dictionary <Variable, Value> inputDataMap = new Dictionary <Variable, Value>()
                {
                    { imageInput, minibatchData[featureStreamInfo].data }
                };

                Dictionary <Variable, Value> outputDataMap = new Dictionary <Variable, Value>()
                {
                    { labelOutput, null }
                };

                model.Evaluate(inputDataMap, outputDataMap, device);
                IList <IList <float> > outputData   = outputDataMap[labelOutput].GetDenseData <float>(labelOutput);
                List <int>             actualLabels = outputData.Select(l => l.IndexOf(l.Max())).ToList();

                int misMatches = actualLabels.Zip(expectedLabels, (a, b) => a.Equals(b) ? 0 : 1).Sum();

                miscountTotal += misMatches;
                Console.WriteLine($"Validating Model: Total Samples = {totalCount}, Misclassify Count = {miscountTotal}");

                if (totalCount > maxCount)
                {
                    break;
                }
            }

            float errorRate = 1.0F * miscountTotal / totalCount;

            Console.WriteLine($"Model Validation Error = {errorRate}");
            return(errorRate);
        }
Exemple #15
0
 public RowToCsvStream(
     StreamInformation streamInformation,
     Stream stream,
     CsvSettings settings
     )
 {
     this.stream            = stream;
     this.streamInformation = streamInformation;
     this.settings          = settings;
 }
Exemple #16
0
        public StreamInformation StreamInfo(string streamName)
        {
            StreamInformation ret = new StreamInformation(CNTKLibPINVOKE.MinibatchSource_StreamInfo__SWIG_0(swigCPtr, streamName), false);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemple #17
0
        public StreamInformation StreamInfo(Variable variableToMatch)
        {
            StreamInformation ret = new StreamInformation(CNTKLibPINVOKE.MinibatchSource_StreamInfo__SWIG_1(swigCPtr, Variable.getCPtr(variableToMatch)), false);

            if (CNTKLibPINVOKE.SWIGPendingException.Pending)
            {
                throw CNTKLibPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemple #18
0
        internal void LoadTextData(CNTK.Variable feature, CNTK.Variable label)
        {
            int imageSize  = feature.Shape.Rank == 1 ? feature.Shape[0] : feature.Shape[0] * feature.Shape[1] * feature.Shape[2];
            int numClasses = label.Shape[0];
            IList <StreamConfiguration> streamConfigurations = new StreamConfiguration[] { new StreamConfiguration(featureStreamName, imageSize), new StreamConfiguration(labelsStreamName, numClasses) };

            miniBatchSource   = MinibatchSource.TextFormatMinibatchSource(FileName, streamConfigurations, MinibatchSource.InfinitelyRepeat);
            featureVariable   = feature;
            labelVariable     = label;
            featureStreamInfo = miniBatchSource.StreamInfo(featureStreamName);
            labelStreamInfo   = miniBatchSource.StreamInfo(labelsStreamName);
        }
Exemple #19
0
        public CsvReader(Stream stream, Encoding defaultEncoding = null, CsvSettings csvSettings = null) :
            base(csvSettings)
        {
            Settings settings = SettingsHome.settingsFactory.buildSettings();

            settings.defaultEncoding = defaultEncoding ?? settings.defaultEncoding;

            streamInformation = new StreamInformation(settings);

            streamFactory = new GenericStreamFactory(stream);
            reader        = new StreamReader(stream, streamInformation.defaultEncoding, streamInformation.detectEncodingFromByteOrderMarks);
        }
        private void PropChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == nameof(SelectedStreamInformation) && SelectedStreamInformation != null && latestSelectedStreamInformation != SelectedStreamInformation)
            { // New information selected, show options dialog and hide the previous one.
                if (latestSelectedStreamInformation != null)
                {
                    latestSelectedStreamInformation.IsSelected = false;
                }

                SelectedStreamInformation.IsSelected = true;

                latestSelectedStreamInformation = SelectedStreamInformation;
            }
        }
        /// <summary>
        /// Deaktiviert den Datenempfang für einen bestimmten Datenstrom.
        /// </summary>
        /// <param name="stream">Die Informationen zum betroffenen Datenstrom.</param>
        /// <exception cref="ArgumentNullException">Es wurden keine Informationen angeben.</exception>
        protected override void OnStop(StreamInformation stream)
        {
            // Validate
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            // Not of interest to us
            if (stream.Consumer != null)
            {
                LegacyDevice.StopFilter(stream.Identifier);
            }
        }
        /// <summary>
        /// Meldet einen Verbraucher für den Inhalt eines bestimmten Datenstroms an.
        /// <seealso cref="SetConsumerState"/>
        /// </summary>
        /// <param name="stream">Die eindeutige Nummer (PID) des Datenstroms in der aktiven
        /// <see cref="SourceGroup"/>.</param>
        /// <param name="type">Die Art der Daten im Datenstrom.</param>
        /// <param name="consumer">Der Empfänger für die Nutzdaten. Die Angabe von <i>null</i>
        /// wird zur Abmeldung verwendet.</param>
        /// <returns>Die eindeutige Kennung des neuen Verbrauchers. Diese Kennung wird benutzt, um
        /// den Datenempfang zu aktivieren, deaktivieren oder den Verbraucher wieder abzumelden.</returns>
        public Guid AddConsumer(ushort stream, StreamTypes type, Action <byte[], int, int> consumer)
        {
            // Report
            if (ConsumerTraceSwitch.Enabled)
            {
                Trace.WriteLine(string.Format(Properties.Resources.Trace_Consumer_Register, stream, type), ConsumerTraceSwitch.DisplayName);
            }

            // Unique identifier of the new registration
            Guid consumerId;

            // Must synchronize
            lock (InstanceSynchronizer)
            {
                // Load the stream information
                StreamInformation info;
                if (m_streamsByPID.TryGetValue(stream, out info))
                {
                    // Report
                    if (ConsumerTraceSwitch.Enabled)
                    {
                        Trace.WriteLine(Properties.Resources.Trace_Consumer_RegisterReuse, ConsumerTraceSwitch.DisplayName);
                    }

                    // Just add to existing registration
                    consumerId = info.AddConsumer(consumer);
                }
                else
                {
                    // Create a brand new one
                    info = new StreamInformation(stream, type, consumer, out consumerId);

                    // Remember it
                    m_streamsByPID[stream] = info;
                }

                // Add to lookup map
                m_streamsById[consumerId] = info;
            }

            // Report
            if (ConsumerTraceSwitch.Enabled)
            {
                Trace.WriteLine(string.Format(Properties.Resources.Trace_Consumer_Identifier, consumerId), ConsumerTraceSwitch.DisplayName);
            }

            // Done
            return(consumerId);
        }
Exemple #23
0
        public void lineBuffering()
        {
            String actual;

            using (Pnyx p = new Pnyx())
            {
                p.setSettings(defaultNewline: StreamInformation.newlineString(NewLineEnum.Windows));
                p.readString(EARTH);
                p.sedAppendLine("The Lord is my shepherd");
                actual = p.processToString();
            }

            const String expected = @"Gaia,Terra,""Mother goddess of the earth""
The Lord is my shepherd";

            Assert.Equal(expected, actual);
        }
        private long ReadOffsets(string currentFileName)
        {
            long position;

            if (streamSource.Exists(offsetsPath) == false)
            {
                return(0);
            }
            using (var offsets = streamSource.OpenRead(offsetsPath))
                using (var reader = new BinaryReader(offsets))
                {
                    var fileName = reader.ReadString();
                    if (fileName != currentFileName)
                    {
                        // wrong file, skipping
                        streamSource.DeleteOnClose(offsetsPath);
                        return(0);
                    }
                    position = reader.ReadInt64();

                    while (true)
                    {
                        string key;
                        try
                        {
                            key = reader.ReadString();
                        }
                        catch (EndOfStreamException)
                        {
                            break;
                        }
                        var pos   = reader.ReadInt64();
                        var count = reader.ReadInt32();

                        idToPos[key] = new StreamInformation
                        {
                            LastPosition = pos,
                            StreamLength = count
                        };
                    }
                }

            return(position);
        }
Exemple #25
0
 /// <summary>
 /// Prüft, ob diese Aufzeichnung zu einem gerade aufgezeichneten Datenstrom gehört.
 /// </summary>
 /// <param name="stream">Ein beliebiger Datenstrom.</param>
 /// <returns>Gesetzt, wenn diese die Aufzeichnung zum Datenstrom ist.</returns>
 public bool Match(StreamInformation stream)
 {
     // Test all
     if (stream == null)
     {
         return(false);
     }
     else if (!Equals(stream.UniqueIdentifier, ScheduleUniqueID.GetValueOrDefault(Guid.Empty)))
     {
         return(false);
     }
     else if (Source == null)
     {
         return(false);
     }
     else
     {
         return(Equals(Source.Source, stream.Source));
     }
 }
Exemple #26
0
        public void rowBuffering()
        {
            String actual;

            using (Pnyx p = new Pnyx())
            {
                p.setSettings(defaultNewline: StreamInformation.newlineString(NewLineEnum.Windows));
                p.readString(EARTH);
                p.parseCsv();
                p.sedAppendRow(new List <String> {
                    "The Lord", "is", "my shepherd"
                });
                actual = p.processToString();
            }

            const String expected = @"Gaia,Terra,""Mother goddess of the earth""
""The Lord"",is,""my shepherd""";

            Assert.Equal(expected, actual);
        }
Exemple #27
0
        /// <summary>
        /// The method is called during Evaluation of the model for specific data set which is specified as an argument
        /// </summary>
        /// <param name="type"></param>
        /// <param name="strFilePath">dataset file path</param>
        /// <param name="streamConfigurations">stream configuration which provides meta-data information</param>
        /// <param name="device"></param>
        /// <returns></returns>
        public static UnorderedMapStreamInformationMinibatchData GetFullBatch(MinibatchType type, string strFilePath, StreamConfiguration[] streamConfigurations, DeviceDescriptor device)
        {
            if (type == MinibatchType.Default)
            {
                var mbs = MinibatchSource.TextFormatMinibatchSource(strFilePath, streamConfigurations, MinibatchSource.FullDataSweep, false);
                //
                var minibatchData = mbs.GetNextMinibatch(int.MaxValue, device);
                //
                return(minibatchData);
            }
            else if (type == MinibatchType.Custom)
            {
                using (var mbreader = new StreamReader(strFilePath))
                {
                    var retVal = nextBatch(mbreader, streamConfigurations, -1, 1, device);
                    var mb     = new UnorderedMapStreamInformationMinibatchData();

                    for (int i = 0; i < retVal.Count; i++)
                    {
                        var k = retVal.ElementAt(i);

                        var key = k.Key;
                        var si  = new StreamInformation();
                        si.m_definesMbSize = streamConfigurations[i].m_definesMbSize;
                        si.m_storageFormat = k.Value.data.StorageFormat;
                        si.m_name          = streamConfigurations[i].m_streamName;

                        var stream = streamConfigurations[i];
                        mb.Add(si, k.Value);
                    }

                    return(mb);
                }
            }
            else
            {
                throw new Exception("Minibatch is not supported.");
            }
        }
Exemple #28
0
        //Function CreateConvolutionalNeuralNetwork(Variable features, int outDims, DeviceDescriptor device, string classifierName)
        //{
        //    // 28x28x1 -> 14x14x4
        //    int kernelWidth1 = 3, kernelHeight1 = 3, numInputChannels1 = 3, outFeatureMapCount1 = 4;
        //    int hStride1 = 2, vStride1 = 2;
        //    int poolingWindowWidth1 = 3, poolingWindowHeight1 = 3;
        //    Function pooling1 = ConvolutionWithMaxPooling(features, device, kernelWidth1, kernelHeight1,
        //        numInputChannels1, outFeatureMapCount1, hStride1, vStride1, poolingWindowWidth1, poolingWindowHeight1);
        //    // 14x14x4 -> 7x7x8
        //    int kernelWidth2 = 3, kernelHeight2 = 3, numInputChannels2 = outFeatureMapCount1, outFeatureMapCount2 = 8;
        //    int hStride2 = 2, vStride2 = 2;
        //    int poolingWindowWidth2 = 3, poolingWindowHeight2 = 3;
        //    Function pooling2 = ConvolutionWithMaxPooling(pooling1, device, kernelWidth2, kernelHeight2,
        //        numInputChannels2, outFeatureMapCount2, hStride2, vStride2, poolingWindowWidth2, poolingWindowHeight2);
        //    Function denseLayer = Dense(pooling2, outDims, device, Activation.None, classifierName);
        //    return denseLayer;
        //}
        private void ImageLoader(string MapFilePath)
        {
            List <CNTKDictionary> transforms = new List <CNTKDictionary> {
                CNTKLib.ReaderScale(ImageDim[0], ImageDim[1], ImageDim[2])
                //          CNTKLib.ReaderMean(meanFilePath)
            };
            var deserializerConfiguration = CNTKLib.ImageDeserializer(MapFilePath,
                                                                      "labels", (uint)NumClasses,
                                                                      "features",
                                                                      transforms);

            MinibatchSourceConfig config = new MinibatchSourceConfig(new List <CNTKDictionary> {
                deserializerConfiguration
            })
            {
                MaxSweeps = 50
            };

            minibatchSource = CNTKLib.CreateCompositeMinibatchSource(config);
            imageStreamInfo = minibatchSource.StreamInfo("features");
            labelStreamInfo = minibatchSource.StreamInfo("labels");
        }
Exemple #29
0
 public IRowProcessor buildRowDestination(StreamInformation streamInformation, Stream stream)
 {
     return(null); // return 'null' if standard line parser (StreamToLineProcessor) is acceptable
 }
Exemple #30
0
 public HeadFilter(StreamInformation streamInformation, int limit)
 {
     this.streamInformation = streamInformation;
     this.limit             = limit;
 }