Sha256: 4c35e41d5a79c582a4d048d41a0b8b5f11d5d91e198fdaf92ff369886141d261

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

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

include DNN::Layers
include DNN::Activations
include DNN::Optimizers
include DNN::Losses
Model = DNN::Model
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]

x_train /= 255
x_test /= 255

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

model = Model.new

model << InputLayer.new(4)

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

model << Dense.new(3)

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-dnn-0.10.4 examples/iris_example.rb
ruby-dnn-0.10.3 examples/iris_example.rb
ruby-dnn-0.10.2 examples/iris_example.rb