Welvet examples

9. architecture — volumetric grid

Open original example ↗Recorded results · not a live execution

Part: II · Foundation
Package: github.com/openfluke/welvet/architecture
Status: ok — ✅

When

You need the architecture foundation package.

Where

import "github.com/openfluke/welvet/architecture"

cd 09-architecture && source ../env.sh && go run .

Why

Networks are spatial (Depth×Rows×Cols×LayersPerCell), not only linear stacks. Topology lives here; compute lives in layer packages.

What

Grid/Cell/Coord, NewGrid, BindOp, HopOrder, SetRemoteLink/ResolveHop. VolumetricNetwork is an alias for Grid.

Sample output (captured)

cells 2

Live capture from go run ./cmd/runall on local ../../welvet (exit 0).

Source

Copied from the Welvet feature book examples (openfluke.github.io/welvet/examples/09-architecture).

main.go

Download source ↓
package main

import (
	"fmt"

	"github.com/openfluke/welvet/architecture"
	"github.com/openfluke/welvet/core"
	"github.com/openfluke/welvet/layers/dense"
)

func main() {
	g := architecture.NewGrid(1, 1, 2, 1) // depth, rows, cols, layersPerCell
	l, _ := dense.New(4, 4, core.ActivationLinear, core.DTypeFloat32)
	if err := dense.Place(g, 0, 0, 0, 0, l); err != nil {
		panic(err)
	}
	_ = g.SetRemoteLink(0, 0, 1, 0, 0, 0, 0, 0) // spatial feedback hop
	fmt.Println("cells", len(g.HopOrder()))
}