Welcome to qeep (pronounced /kēp/)! This project implements a deep learning framework in Go. It allows you to define neural networks in a declarative way while being able to control operations at tensor level.
- 📐 Multi-Dimensional Tensors with a wide range of linear algebra and statistical operations.
- 🔁 Automatic differentiation (AutoGrad) for tensors.
- ⚡ GPU acceleration via CUDA for high-performance large tensor computations.
- 🧱 A variety of neural network components, such as fully connected (
FC) layer. - 📝A declarative API for defining neural networks using
streampackage.
Navigate to your project directory and clone the qeep repository:
git clone https://github.com/sahandsafizadeh/qeep
Ensure that you have Go installed. Then, Link the local qeep package to your project using Go modules:
go mod edit -require=github.com/sahandsafizadeh/qeep@v0.0.0
go mod edit -replace=github.com/sahandsafizadeh/qeep=./qeep
go mod tidy
💡 This setup assumes that qeep is cloned into a local folder named ./qeep relative to your Go project.
Here is an example of defining a classification model:
package main
import (
"github.com/sahandsafizadeh/qeep/component/layers"
"github.com/sahandsafizadeh/qeep/component/layers/activations"
"github.com/sahandsafizadeh/qeep/component/losses"
"github.com/sahandsafizadeh/qeep/component/optimizers"
"github.com/sahandsafizadeh/qeep/model"
"github.com/sahandsafizadeh/qeep/model/stream"
"github.com/sahandsafizadeh/qeep/tensor"
)
const dev = tensor.CPU
func prepareModel() (m *model.Model, err error) {
input := stream.Input()
x := stream.FC(&layers.FCConfig{Inputs: 4, Outputs: 16, Device: dev})(input)
x = stream.Relu()(x)
x = stream.Dropout(&layers.DropoutConfig{Rate: 0.3})(x)
x = stream.FC(&layers.FCConfig{Inputs: 16, Outputs: 3, Device: dev})(x)
output := stream.Softmax(&activations.SoftmaxConfig{Dim: 1})(x)
/* -------------------- */
loss := losses.NewCE()
optimizer, err := optimizers.NewAdamW(&optimizers.AdamWConfig{
LearningRate: 1e-5,
WeightDecay: optimizers.AdamWDefaultWeightDecay,
Beta1: optimizers.AdamWDefaultBeta1,
Beta2: optimizers.AdamWDefaultBeta2,
Eps: optimizers.AdamWDefaultEps,
})
if err != nil {
return
}
m, err = model.NewModel(input, output, &model.ModelConfig{
Loss: loss,
Optimizer: optimizer,
})
if err != nil {
return
}
return m, nil
}
📂 More working examples are provided. You can download their dataset and run them like the following for Iris Classification:
cd ./qeep/examples/03-Iris/
curl -o data.csv https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data
go run .
- An accessible CUDA-capable GPU.
- CUDA Toolkit installed.
- A working C Toolchain like
gcc. - CGO enabled and configured (setup guide).
Build the necessary CUDA libraries once:
Now in your Go code, you can set devices to tensor.CUDA.
🔥 Finally, run your program with the cuda build tag:
The qeep project is licensed under the MIT License. See the LICENSE file for details.