Sha256: 61d72e669ac43b8ae08c3edefd223a682a241c051a2033ab2233df43ffc220da
Contents?: true
Size: 431 Bytes
Versions: 1
Compression:
Stored size: 431 Bytes
Contents
# frozen_string_literal: true module Micrograd class Neuron def initialize(n) @weights = Array.new(n) { random_value } @bias = random_value end attr_reader :weights, :bias def call(xs) weights.zip(xs) .sum(bias) { |w, x| w * x } .tanh end def parameters = [*weights, bias] private def random_value Value.new(Random.rand(-1.0..1.0)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
micrograd-0.1.0 | lib/micrograd/neuron.rb |