Sha256: f7ffcd580f8f8c5c80106dc5537004b8099dd4bb61f59e600ad528c1586570d8

Contents?: true

Size: 1.26 KB

Versions: 100

Compression:

Stored size: 1.26 KB

Contents

require "./forward.rb"
require "./sigmoid.rb"
require "./random.rb"

# proc do |xs,ws|
#     (xs.zip(ws).map { |x,w| x*w }.reduce(:+))[27..20]
# end

# 16:16 Fixed-point type.
[31..0].signed.typedef(:fix32)
# Multiply must adjust point.
fix32.define_operator(:*) do |left,right|
   ( left.as([31..0]) * right ) >> 32
end


##
# A fully specified forward module with 8.24-bit fixed point computation
# and 4.4bit table-based sigmoid activation function.
# Structure: 2 inputs, one 3-column hidden layer and 2 outputs.

system :forward_sub, forward(
    fix32,   # Data type
    [2,4,3,2], # NN structure
    [
        # Input samples.
          # First input.
        [[_sh08000000, _sh08000000, _sh05000000, _sh05000000, 
          *([_sh00000000]*28)],
          # Second input.
         [_sh08000000, _sh05000000, _sh08000000, _sh05000000,
          *([_sh00000000]*28)]],
        # Expected outputs
          # First output
        [[_sh01000000, _sh00000000, _sh00000000, _sh00000000, 
          *([_sh00000000]*28)],
          # Second output
         [_sh00000000, _sh01000000, _sh01000000, _sh01000000,
          *([_sh00000000]*28)]]
    ],
    # Biases initial values
    rand_array([4,3,2],32),
    # Weights initial values
    rand_array([[2,2,2,2],[4,4,4],[3,3]],32)
) do
end

Version data entries

100 entries across 100 versions & 1 rubygems

Version Path
HDLRuby-3.4.0 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-3.3.4 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-3.3.3 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-3.3.1 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-3.3.0 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-3.2.0 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-3.1.0 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-3.0.0 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.12 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.11 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.10 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.9 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.8 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.7 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.5 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.4 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.3 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.2 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.11.0 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.10.5 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb