-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from Sergio0694/dev
Serialization and other changes
- Loading branch information
Showing
54 changed files
with
1,489 additions
and
1,205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
NeuralNetwork.NET.Cuda/APIs/CuDnnNetworkLayersDeserializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using JetBrains.Annotations; | ||
using NeuralNetworkNET.APIs.Delegates; | ||
using NeuralNetworkNET.APIs.Enums; | ||
using NeuralNetworkNET.APIs.Interfaces; | ||
using NeuralNetworkNET.Cuda.Layers; | ||
using System.IO; | ||
|
||
namespace NeuralNetworkNET.APIs | ||
{ | ||
/// <summary> | ||
/// A static class that exposes a single deserialization method that can be used to load a saved network using the cuDNN layers | ||
/// </summary> | ||
public static class CuDnnNetworkLayersDeserializer | ||
{ | ||
/// <summary> | ||
/// Gets the <see cref="LayerDeserializer"/> instance to load cuDNN network layers | ||
/// </summary> | ||
[PublicAPI] | ||
public static LayerDeserializer Deserializer { get; } = Deserialize; | ||
|
||
/// <summary> | ||
/// Deserializes a layer of the given type from the input <see cref="Stream"/> | ||
/// </summary> | ||
/// <param name="stream">The <see cref="Stream"/> to use to load the layer data</param> | ||
/// <param name="type">The type of network layer to return</param> | ||
private static INetworkLayer Deserialize([NotNull] Stream stream, LayerType type) | ||
{ | ||
switch (type) | ||
{ | ||
case LayerType.FullyConnected: return CuDnnFullyConnectedLayer.Deserialize(stream); | ||
case LayerType.Convolutional: return CuDnnConvolutionalLayer.Deserialize(stream); | ||
case LayerType.Pooling: return CuDnnPoolingLayer.Deserialize(stream); | ||
case LayerType.Softmax: return CuDnnSoftmaxLayer.Deserialize(stream); | ||
default: return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.IO; | ||
using JetBrains.Annotations; | ||
using NeuralNetworkNET.APIs.Enums; | ||
using NeuralNetworkNET.APIs.Interfaces; | ||
|
||
namespace NeuralNetworkNET.APIs.Delegates | ||
{ | ||
/// <summary> | ||
/// A <see cref="delegate"/> that tries to deserialize a network layer from the input <see cref="Stream"/>, assuming the layer is of the given <see cref="LayerType"/> | ||
/// </summary> | ||
/// <param name="stream">The source <see cref="Stream"/> to load data from. If the layer type is not supported, the <see cref="Stream"/> should not be read at all</param> | ||
/// <param name="type">The type of network layer to deserialize from the <see cref="Stream"/></param> | ||
[CanBeNull] | ||
public delegate INetworkLayer LayerDeserializer([NotNull] Stream stream, LayerType type); | ||
} |
2 changes: 1 addition & 1 deletion
2
...rk.NET.Cuda/APIs/Enums/ConvolutionMode.cs → ...Network.NET/APIs/Enums/ConvolutionMode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.