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-2.6.2 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.5.1 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.5.0 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.29 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.28 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.27 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.26 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.25 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.22 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.21 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.20 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.19 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.18 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.17 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.15 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.14 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.12 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.11 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.10 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb
HDLRuby-2.4.9 lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb