Sha256: 0bbd5d1afabec31a4868fb261b8d2198b72ceb9ee1b5e311482ff18b344b27eb

Contents?: true

Size: 718 Bytes

Versions: 6

Compression:

Stored size: 718 Bytes

Contents

require "dnn"
require "dnn/datasets/iris"
# If you use numo/linalg then please uncomment out.
# require "numo/linalg/autoloader"

include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
Iris = DNN::Iris

x, y = Iris.load(true)
x_train, y_train = x[0...100, true], y[0...100]
x_test, y_test = x[100...150, true], y[100...150]

y_train = DNN::Utils.to_categorical(y_train, 3, Numo::SFloat)
y_test = DNN::Utils.to_categorical(y_test, 3, Numo::SFloat)

model = Sequential.new

model << InputLayer.new(4)

model << Dense.new(64)
model << ReLU.new

model << Dense.new(3)

model.setup(Adam.new, SoftmaxCrossEntropy.new)

model.train(x_train, y_train, 1000, batch_size: 10, test: [x_test, y_test])

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-dnn-0.15.1 examples/iris_example.rb
ruby-dnn-0.15.0 examples/iris_example.rb
ruby-dnn-0.14.3 examples/iris_example.rb
ruby-dnn-0.14.2 examples/iris_example.rb
ruby-dnn-0.14.1 examples/iris_example.rb
ruby-dnn-0.14.0 examples/iris_example.rb