コード例 #1
0
        /// <inheritdoc />
        public override Dictionary <string, INDArray> ExtractDirectFrom(object readData, int numberOfRecords, IComputationHandler handler)
        {
            Dictionary <string, INDArray> unprocessedNamedArrays = (Dictionary <string, INDArray>)readData;
            Dictionary <string, INDArray> processedNamedArrays   = new Dictionary <string, INDArray>();

            foreach (string sectionName in unprocessedNamedArrays.Keys)
            {
                INDArray processedArray = unprocessedNamedArrays[sectionName];

                if (processedArray.Shape[0] != numberOfRecords)
                {
                    long[] beginIndices = (long[])processedArray.Shape.Clone();
                    long[] endIndices   = (long[])processedArray.Shape.Clone();

                    beginIndices = NDArrayUtils.GetSliceIndicesAlongDimension(0, 0, beginIndices, copyResultShape: false, sliceEndIndex: false);
                    endIndices   = NDArrayUtils.GetSliceIndicesAlongDimension(0, Math.Min(numberOfRecords, processedArray.Shape[0]), endIndices, copyResultShape: false, sliceEndIndex: true);

                    processedArray = processedArray.Slice(beginIndices, endIndices);
                }

                if (ProcessedSectionNames == null || ProcessedSectionNames.Contains(sectionName))
                {
                    processedArray = ProcessDirect(processedArray, handler);
                }

                processedNamedArrays.Add(sectionName, processedArray);
            }

            return(processedNamedArrays);
        }