Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def geneateRandomWeight(shape: Int*): Tensor = 2 * np.rand(shape.toArray) - 1
- val biasedTrainSet = np.concatenate(Seq(trainSet, np.ones(trainSet.shape(0)).T), 1)
- def initializeWeights(layers: List[Int], weights: List[Tensor] = List()): List[Tensor] = {
- // the last layer is our networks target, so doesn't need any further weights
- if(layers.length < 2) return weights
- // the second last layer doesn't need to take an account an additional bias column
- if(layers.length == 2) weights :+ geneateRandomWeight(layers.head + 1, layers.last)
- // generate weigths aware of added bias column
- else initializeWeights(layers.tail, weights :+ geneateRandomWeight(layers.head + 1, layers.tail.head + 1))
- }
Add Comment
Please, Sign In to add comment