All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.komputation.cuda.network.CudaBackwardPropagation.kt Maven / Gradle / Ivy

Go to download

Komputation is a neural network framework for the JVM written in the Kotlin programming language.

There is a newer version: 0.12.5
Show newest version
package com.komputation.cuda.network

import jcuda.Pointer
import com.komputation.cuda.layers.CudaEntryPoint
import com.komputation.cuda.layers.CudaForwardLayer

class CudaBackwardPropagator(
    private val entryPoint: CudaEntryPoint,
    private val layers : Array) {

    private val numberLayers = this.layers.size

    fun backward(lossGradient : Pointer, batchSize: Int): Pointer {

        var chain = lossGradient

        for(indexLayer in this.numberLayers - 1 downTo 0) {

            val layer = this.layers[indexLayer]

            chain = layer.backward(batchSize, chain)

        }

        return this.entryPoint.backward(chain)

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy