Sha256: 82487d23bff472aa5ead0bbaee4339c4445e2766416f08eae4e6a3d66bcf2729

Contents?: true

Size: 425 Bytes

Versions: 24

Compression:

Stored size: 425 Bytes

Contents

require "dnn"

include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses

x = Numo::SFloat[[0, 0], [1, 0], [0, 1], [1, 1]]
y = Numo::SFloat[[0], [1], [1], [0]]

model = Sequential.new

model << InputLayer.new(2)
model << Dense.new(16)
model << ReLU.new
model << Dense.new(1)

model.setup(SGD.new, SigmoidCrossEntropy.new)

model.train(x, y, 20000, batch_size: 4, verbose: false)

p model.predict(x)

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
ruby-dnn-1.3.0 examples/xor_example.rb
ruby-dnn-1.2.3 examples/xor_example.rb
ruby-dnn-1.2.2 examples/xor_example.rb
ruby-dnn-1.2.1 examples/xor_example.rb
ruby-dnn-1.2.0 examples/xor_example.rb
ruby-dnn-1.1.6 examples/xor_example.rb
ruby-dnn-1.1.5 examples/xor_example.rb
ruby-dnn-1.1.4 examples/xor_example.rb
ruby-dnn-1.1.3 examples/xor_example.rb
ruby-dnn-1.1.2 examples/xor_example.rb
ruby-dnn-1.1.1 examples/xor_example.rb
ruby-dnn-1.1.0 examples/xor_example.rb
ruby-dnn-1.0.0 examples/xor_example.rb
ruby-dnn-0.16.2 examples/xor_example.rb
ruby-dnn-0.16.1 examples/xor_example.rb
ruby-dnn-0.16.0 examples/xor_example.rb
ruby-dnn-0.15.3 examples/xor_example.rb
ruby-dnn-0.15.2 examples/xor_example.rb
ruby-dnn-0.15.1 examples/xor_example.rb
ruby-dnn-0.15.0 examples/xor_example.rb