コード例 #1
0
        public static INeuralNetwork TryLoad([NotNull] Stream stream, ExecutionModePreference preference)
        {
            try
            {
                using (GZipStream gzip = new GZipStream(stream, CompressionMode.Decompress))
                {
                    if (!gzip.TryRead(out NetworkType model))
                    {
                        return(null);
                    }
                    switch (model)
                    {
                    case NetworkType.Sequential: return(SequentialNetwork.Deserialize(gzip, preference));

                    case NetworkType.ComputationGraph: return(ComputationGraphNetwork.Deserialize(gzip, preference));

                    default: return(null);
                    }
                }
            }
            catch
            {
                // Locked or invalid file
                return(null);
            }
        }
コード例 #2
0
        public NodeBuilder Sum(ActivationType activation, params NodeBuilder[] inputs)
        {
            ExecutionModePreference mode = CuDnnNetworkLayers.IsCudaSupportAvailable
                ? ExecutionModePreference.Cuda
                : ExecutionModePreference.Cpu;

            return(New(ComputationGraphNodeType.Sum, (activation, mode), inputs));
        }
コード例 #3
0
 public static INeuralNetwork TryLoad([NotNull] FileInfo file, ExecutionModePreference preference)
 {
     try
     {
         using (FileStream stream = file.OpenRead())
             return(TryLoad(stream, preference));
     }
     catch (FileNotFoundException)
     {
         // Just keep going
         return(null);
     }
 }
コード例 #4
0
 public NodeBuilder Sum(ActivationType activation, ExecutionModePreference mode, params NodeBuilder[] inputs) => New(ComputationGraphNodeType.Sum, (activation, mode), inputs);