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); } }
public NodeBuilder Sum(ActivationType activation, params NodeBuilder[] inputs) { ExecutionModePreference mode = CuDnnNetworkLayers.IsCudaSupportAvailable ? ExecutionModePreference.Cuda : ExecutionModePreference.Cpu; return(New(ComputationGraphNodeType.Sum, (activation, mode), inputs)); }
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); } }
public NodeBuilder Sum(ActivationType activation, ExecutionModePreference mode, params NodeBuilder[] inputs) => New(ComputationGraphNodeType.Sum, (activation, mode), inputs);