INNER CODE UNIT · Go

keys

takara-ai/go-attention · cmd/demo/main.go:74

    keys := make(attention.Matrix, batchSize*seqLen)
    values := make(attention.Matrix, batchSize*seqLen)
    
    // Initialize with a deterministic pattern
    for i := 0; i < batchSize*seqLen; i++ {
        queries[i] = make(attention.Vector, config.DModel)
        keys[i] = make(attention.Vector, config.DModel)
        values[i] = make(attention.Vector, config.DModel)
        for j := 0; j < config.DModel; j++ {
            val := float64(i*j) / float64(config.DModel)
            queries[i][j] = val
            keys[i][j] = val
            values[i][j] = val
        }
    }

    // Process through multi-head attention
    output, err := mha.Forward(queries, keys, values)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…