Skip to content

Commit ce33052

Browse files
committed
Update to v1.1.13
1 parent f233749 commit ce33052

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

src/ParallelReverseAutoDiff.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
33
<metadata>
44
<id>ParallelReverseAutoDiff</id>
5-
<version>1.1.12</version>
5+
<version>1.1.13</version>
66
<authors>ameritusweb</authors>
77
<owners>ameritusweb</owners>
88
<license type="expression">LGPL-2.1-only</license>
@@ -11,7 +11,7 @@
1111
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1212
<description>A library for parallelized reverse mode automatic differentiation in C# for custom neural network development.</description>
1313
<repository type="git" url="https://github.com/ameritusweb/ParallelReverseAutoDiff.git" commit="0a9bbd18f45c4f4434160a7c064539f29f3a3c67" />
14-
<releaseNotes>Update visitor.</releaseNotes>
14+
<releaseNotes>Remove console logging.</releaseNotes>
1515
<copyright>ameritusweb, 2023</copyright>
1616
<tags>autodiff automatic-differentiation parallel reverse-mode differentiation C# neural network</tags>
1717
<dependencies>

src/docs/README.md

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ Parallel Reverse Mode Automatic Differentiation in C#
77
![Nuget](https://img.shields.io/nuget/dt/parallelreverseautodiff?style=flat-square)
88
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/7f9f69794dd74a97aeaac17ebd1580ec)](https://app.codacy.com/gh/ameritusweb/ParallelReverseAutoDiff/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
99

10+
## Table of Contents
11+
- [Overview](#overview)
12+
- [Building your Neural Network Model](#building-your-neural-network-model)
13+
- [Understanding the JSON Architecture](#understanding-the-json-architecture)
14+
- [Instantiating the Architecture](#instantiating-the-architecture)
15+
- [Instantiating the Computational Graph](#instantiating-the-computational-graph)
16+
- [Populating the Backward Dependency Counts](#populating-the-backward-dependency-counts)
17+
- [Running the Forward Pass](#running-the-forward-pass)
18+
- [Creating a Loss Function](#creating-a-loss-function)
19+
- [Running the Backward Pass](#running-the-backward-pass)
20+
- [Clipping the Gradients](#clipping-the-gradients)
21+
- [Updating the Weights](#updating-the-weights)
22+
- [Using CUDA Operations](#using-cuda-operations)
23+
- [Customization](#customization)
24+
- [Custom Neural Network Operations](#custom-neural-network-operations)
25+
- [Support Developer](#support-developer)
26+
- [Star the Project](#star-the-project)
27+
- [Reporting Bugs](#reporting-bugs)
28+
1029
ParallelReverseAutoDiff (PRAD) is a thread-safe C# library designed for reverse mode automatic differentiation, optimized for parallel computation and primed for the demands of modern machine learning applications and neural network training. It leverages semaphores and locks to orchestrate between threads, ensuring precision during gradient accumulation.
1130

1231
Upon the realm of code, a gem does shine,
@@ -42,6 +61,8 @@ Etched forever in code's vast story.
4261

4362
[API Documentation](https://ameritusweb.github.io/ParallelReverseAutoDiff/api/index.html)
4463

64+
## Overview
65+
4566
Each operation in PRAD is embodied as a node with forward and backward functions, facilitating the efficient calculation of derivatives. This design is particularly beneficial for large-scale problems and complex neural network architectures, where computational efficiency is paramount.
4667

4768
A standout feature of PRAD is its innovative use of the visitor pattern. The library includes a specialized 'Neural Network Visitor' which traverses neural network nodes across different threads. This visitor is tasked with gradient accumulation on nodes shared across multiple threads, allowing for parallelized computations while maintaining consistency and avoiding race conditions.
@@ -50,11 +71,9 @@ Moreover, PRAD introduces a data-driven approach to neural network architecture
5071

5172
PRAD's dynamic computational graph, constructed from JSON architecture, allows for the efficient computation of gradients, a crucial aspect of the backpropagation process used in training neural networks. This unique blend of features makes PRAD an efficient, scalable, and groundbreaking automatic differentiation solution.
5273

53-
## Prerequisites
74+
### Prerequisites
5475
Download and install the [Cuda Toolkit 12.0](https://developer.nvidia.com/cuda-12-0-0-download-archive) if you want to use the CudaMatrixMultiplyOperation.
5576

56-
## Supported Operations
57-
5877
### Regular Operations
5978
AddGaussianNoiseOperation
6079

@@ -140,7 +159,7 @@ DeepScaleAndShiftOperation
140159

141160
FlattenOperation
142161

143-
## Neural Network Parameters
162+
### Neural Network Parameters
144163

145164
Each neural network base class has a set of parameters that can be used to configure the neural network. They are as follows:
146165

@@ -243,7 +262,7 @@ public List<Matrix> ChosenActions { get; set; }
243262

244263
## Usage
245264

246-
### Build out your neural network model
265+
### Building your Neural Network Model
247266

248267
```csharp
249268
var embeddingLayerBuilder = new ModelLayerBuilder(this)
@@ -287,7 +306,7 @@ The model element group's elements are stored in a matrix whose size is specifie
287306

288307
In this example, for the hidden layer, the first dimension is the number of layers and the second and third dimensions are the row and column sizes respectively.
289308

290-
### Create an architecture JSON file
309+
### Understanding the JSON Architecture
291310

292311
Here is an example:
293312
```json
@@ -636,15 +655,15 @@ The JSON defines the steps in a machine learning model's forward pass and also s
636655

637656
By defining the operations and their connections in a JSON file, the graph can be easily constructed and modified, and the computations can be automatically differentiated and parallelized. This representation makes it possible to define a wide variety of models in a modular way, using the building blocks provided by the library.
638657

639-
### Instantiate the architecture
658+
### Instantiating the Architecture
640659

641660
Use a JSON serialization library like Newtonsoft.JSON to deserialize the JSON file to a JsonArchitecture object.
642661

643662
There are other JSON architectures available as well.
644663

645664
These include the 'NestedLayersJsonArchitecture', 'DualLayersJsonArchitecture', and 'TripleLayersJsonArchitecture'.
646665

647-
### Instantiate the computational graph
666+
### Instantiating the Computational Graph
648667

649668
```c#
650669
// Retrieve the matrices from the model layers created by the model layer builder.
@@ -740,7 +759,7 @@ this.computationGraph
740759

741760
Operation finders are a key component used to define and locate different operations in a neural network's computational graph. They're essentially functions that link to specific operations at different layers or time steps within the network. This is achieved by mapping string identifiers (IDs) to these operations, which are then used within a JSON architecture to establish the network's structure and sequence of computations. For example, an operation finder could link to a matrix multiplication operation in a specific layer of the network. By using these operation finders, developers can effectively manage complex computational graphs.
742761

743-
### Populate the backward dependency counts
762+
### Populating the Backward Dependency Counts
744763

745764
Then populate the backward dependency counts by running the following code. It only has to be run once to set up the backward dependency counts.
746765
```c#
@@ -754,7 +773,7 @@ for (int t = this.Parameters.NumTimeSteps - 1; t >= 0; t--)
754773
}
755774
```
756775

757-
### Run the forward pass
776+
### Running the Forward Pass
758777
```c#
759778
var op = this.computationGraph.StartOperation ?? throw new Exception("Start operation should not be null.");
760779
IOperationBase? currOp = null;
@@ -779,14 +798,14 @@ do
779798
while (currOp.Next != null);
780799
```
781800

782-
### Create a loss function
801+
### Creating a Loss Function
783802
Create a loss function like mean squared error, cross-entropy loss or using policy gradient methods.
784803

785804
Then calculate the gradient of the loss with respect to the output.
786805

787806
Plug the result in as the backward input for the backward start operation.
788807

789-
### Run the backward pass utilizing inherent parallelization
808+
### Running the Backward Pass
790809
```c#
791810
IOperationBase? backwardStartOperation = null;
792811
for (int t = this.Parameters.NumTimeSteps - 1; t >= 0; t--)
@@ -805,19 +824,19 @@ for (int t = this.Parameters.NumTimeSteps - 1; t >= 0; t--)
805824
}
806825
```
807826

808-
### Clip the gradients
827+
### Clipping the Gradients
809828
```c#
810829
GradientClipper clipper = new GradientClipper(this);
811830
clipper.Clip(new[] { this.embeddingLayer, this.hiddenLayer, this.outputLayer });
812831
```
813832

814-
### Update the weights
833+
### Updating the Weights
815834
```c#
816835
AdamOptimizer optimizer = new AdamOptimizer(this);
817836
optimizer.Optimize(new[] { this.embeddingLayer, this.hiddenLayer, this.outputLayer });
818837
```
819838

820-
### Using CUDA operations
839+
### Using CUDA Operations
821840
```c#
822841
Cudablas.Instance.DeviceId = 0; // set the GPU to use, defaults to 0
823842
Cudablas.Instance.Initialize(); // initialize the CUDA library
@@ -894,14 +913,14 @@ In this example, the Forward method calculates the average of the features for e
894913

895914
This level of customization allows PRAD to be a versatile tool in the field of machine learning, capable of being tailored to a wide range of tasks, datasets, and innovative architectures.
896915

897-
## Support developer
916+
## Support Developer
898917
[!["Buy Me A Coffee"](https://raw.githubusercontent.com/ameritusweb/ParallelReverseAutoDiff/main/docs/orange_img.png)](https://www.buymeacoffee.com/ameritusweb)
899918

900-
## Like the project?
919+
## Star the Project
901920

902921
Give it a :star: Star!
903922

904-
## Found a bug?
923+
## Reporting Bugs
905924

906925
Drop to [Issues](https://github.com/ameritusweb/ParallelReverseAutoDiff/issues)
907926

0 commit comments

Comments
 (0)