Sha256: 3226ac196f5c18448b7eef49c611478f707bdd8ed506ba703d88da0f486ba032

Contents?: true

Size: 470 Bytes

Versions: 6

Compression:

Stored size: 470 Bytes

Contents

require "dnn"

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

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 DNN::Utils.sigmoid(model.predict(x))

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-dnn-0.13.4 examples/xor_example.rb
ruby-dnn-0.13.3 examples/xor_example.rb
ruby-dnn-0.13.2 examples/xor_example.rb
ruby-dnn-0.13.1 examples/xor_example.rb
ruby-dnn-0.13.0 examples/xor_example.rb
ruby-dnn-0.12.4 examples/xor_example.rb