Sha256: 5255f597a1fad9308395834caa5801de11792598b921b94d3a61bfbe7ca6e22c

Contents?: true

Size: 453 Bytes

Versions: 16

Compression:

Stored size: 453 Bytes

Contents

require "dnn"

include DNN::Layers
include DNN::Activations
include DNN::Optimizers
Model = DNN::Model

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

model = Model.new

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

model.compile(SGD.new)

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

p model.predict(x)

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby-dnn-0.8.8 examples/xor_example.rb
ruby-dnn-0.8.7 examples/xor_example.rb
ruby-dnn-0.8.6 examples/xor_example.rb
ruby-dnn-0.8.5 examples/xor_example.rb
ruby-dnn-0.8.4 examples/xor_example.rb
ruby-dnn-0.8.3 examples/xor_example.rb
ruby-dnn-0.8.2 examples/xor_example.rb
ruby-dnn-0.8.1 examples/xor_example.rb
ruby-dnn-0.8.0 examples/xor_example.rb
ruby-dnn-0.7.3 examples/xor_example.rb
ruby-dnn-0.7.2 examples/xor_example.rb
ruby-dnn-0.7.1 examples/xor_example.rb
ruby-dnn-0.7.0 examples/xor_example.rb
ruby-dnn-0.6.10 examples/xor_example.rb
ruby-dnn-0.6.9 examples/xor_example.rb
ruby-dnn-0.6.8 examples/xor_example.rb