source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | zethussuen/epic-editor-rails | https://github.com/zethussuen/epic-editor-rails | Rakefile | Ruby | mit | 47 | master | 1,654 | require 'open-uri'
begin
require File.expand_path('../config/application', __FILE__)
EpicEditorRails::Application.load_tasks
rescue LoadError
end
# rake update[param]
# param can be a tag name, a branch name, or a commit hash on https://github.com/OscarGodson/EpicEditor
# It defaults to 'develop' (ie, the develop... |
github | zethussuen/epic-editor-rails | https://github.com/zethussuen/epic-editor-rails | lib/epic-editor-rails/engine.rb | Ruby | mit | 47 | master | 488 | module Epic
module Editor
module Rails
class Engine < ::Rails::Engine
if ::Rails.version >= "3.1"
initializer "Precompile EpicEditor assets" do |app|
app.config.assets.precompile += [
"epiceditor.js", "base/epiceditor.css",
"editor/epic-dark.css", "e... |
github | coderanger/knife-solve | https://github.com/coderanger/knife-solve | Rakefile | Ruby | apache-2.0 | 47 | master | 1,032 | #
# Copyright 2014-2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... |
github | coderanger/knife-solve | https://github.com/coderanger/knife-solve | Gemfile | Ruby | apache-2.0 | 47 | master | 625 | #
# Copyright 2014-2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... |
github | coderanger/knife-solve | https://github.com/coderanger/knife-solve | knife-solve.gemspec | Ruby | apache-2.0 | 47 | master | 1,565 | #
# Copyright 2014-2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... |
github | coderanger/knife-solve | https://github.com/coderanger/knife-solve | spec/solve_spec.rb | Ruby | apache-2.0 | 47 | master | 2,827 | #
# Copyright 2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... |
github | coderanger/knife-solve | https://github.com/coderanger/knife-solve | spec/spec_helper.rb | Ruby | apache-2.0 | 47 | master | 1,014 | #
# Copyright 2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... |
github | coderanger/knife-solve | https://github.com/coderanger/knife-solve | lib/knife-solve.rb | Ruby | apache-2.0 | 47 | master | 608 | #
# Copyright 2014-2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... |
github | coderanger/knife-solve | https://github.com/coderanger/knife-solve | lib/knife-solve/version.rb | Ruby | apache-2.0 | 47 | master | 632 | #
# Copyright 2014-2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... |
github | coderanger/knife-solve | https://github.com/coderanger/knife-solve | lib/chef/knife/solve.rb | Ruby | apache-2.0 | 47 | master | 2,501 | #
# Copyright 2014-2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | ruby-dnn.gemspec | Ruby | mit | 47 | master | 1,241 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "dnn/version"
Gem::Specification.new do |spec|
spec.name = "ruby-dnn"
spec.version = DNN::VERSION
spec.authors = ["unagiootoro"]
spec.email = ["ootoro838861@outlook.jp"]
sp... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | Rakefile | Ruby | mit | 47 | master | 816 | require "bundler/gem_tasks"
require "rake/testtask"
require "rake/extensiontask"
require "yard"
require "yard/rake/yardoc_task"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "ext"
t.libs << "lib"
t.test_files = FileList["test/*_test.rb", "test/functions_test/*_test.rb", "test/layers_test/*_test.r... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/models_test.rb | Ruby | mit | 47 | master | 10,500 | require "test_helper"
require "json"
include DNN::Layers
include DNN::Optimizers
include DNN::Initializers
include DNN::Losses
include DNN::Models
class StubMultiInputModel < DNN::Models::Model
def initialize(dense1, dense2)
super()
@dense1 = dense1
@dense2 = dense2
end
def forward(x1, x2)
y1 =... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/losses_test.rb | Ruby | mit | 47 | master | 4,945 | require "test_helper"
class TestMeanSquaredError < MiniTest::Unit::TestCase
# It is matches the expected value of forward.
def test_forward
loss = DNN::Losses::MeanSquaredError.new
y = DNN::Tensor.new(Xumo::SFloat[[0, 1]])
t = DNN::Tensor.new(Xumo::SFloat[[2, 4]])
out_y = loss.(y, t)
assert_equ... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/process_runner_test.rb | Ruby | mit | 47 | master | 1,541 | require "test_helper"
require "json"
class TestProcessRunner < MiniTest::Unit::TestCase
# It is including callback function in @callback.
def test_add_callback
runner = DNN::ProcessRunner.new
cbk = DNN::Callbacks::LambdaCallback.new(:before_epoch) {}
runner.add_callback(cbk)
assert_equal [cbk], run... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/callbacks_test.rb | Ruby | mit | 47 | master | 3,198 | require "test_helper"
class TestLambdaCallback < MiniTest::Unit::TestCase
def test_initialize
cbk = DNN::Callbacks::LambdaCallback.new(:before_epoch) { return true }
assert_equal true, cbk.before_epoch
end
end
class TestEarlyStopping < MiniTest::Unit::TestCase
def test_after_train_on_batch
cbk = DNN... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/utils_test.rb | Ruby | mit | 47 | master | 674 | require "test_helper"
Utils = DNN::Utils
class TestUtils < MiniTest::Unit::TestCase
def test_to_categorical
y = Xumo::NArray[0, 3]
y2 = Utils.to_categorical(y, 5)
assert_equal Xumo::NArray[[1, 0, 0, 0, 0], [0, 0, 0, 1, 0]], y2
end
def test_to_categorical2
y = Xumo::NArray[0, 3]
y2 = Utils.t... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/regularizers_test.rb | Ruby | mit | 47 | master | 2,957 | require "test_helper"
class TestL1 < MiniTest::Unit::TestCase
def test_from_hash
hash = {
class: "DNN::Regularizers::L1",
l1_lambda: 0.1,
}
l1 = DNN::Regularizers::L1.from_hash(hash)
assert_equal 0.1, l1.l1_lambda
end
def test_forward
param = DNN::Variable.new(Xumo::SFloat[-2, 2]... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/test_helper.rb | Ruby | mit | 47 | master | 417 | $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "dnn"
require "minitest/autorun"
Xumo = DNN::Xumo
class DNN::Xumo::SFloat
alias _round round
def round(ndigits = nil)
return self.map { |f| f.round(ndigits)} if ndigits
_round
end
end
class DNN::Xumo::DFloat
alias _round round
def ... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/evaluator_test.rb | Ruby | mit | 47 | master | 918 | require "test_helper"
class TestEvaluator < MiniTest::Unit::TestCase
# It is accuracy is 1.
def test_evaluate
model = DNN::Models::Sequential.new
model << DNN::Layers::InputLayer.new(3)
model.setup(DNN::Optimizers::SGD.new, DNN::Losses::MeanSquaredError.new)
x = Xumo::SFloat[[0, 0.5, 1], [0.5, 1, 0... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/trainer_test.rb | Ruby | mit | 47 | master | 637 | require "test_helper"
class TestTrainer < MiniTest::Unit::TestCase
def test_metrics_to_str
met = { accuracy: 0.00011, test_loss: 0.00011 }
str_met = "accuracy: 0.0001, test_loss: 0.0001"
trainer = DNN::Trainer.new(DNN::Models::Model.new)
assert_equal str_met, trainer.send(:metrics_to_str, met)
end
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/initializers_test.rb | Ruby | mit | 47 | master | 4,231 | require "test_helper"
include DNN::Layers
include DNN::Optimizers
include DNN::Initializers
class TestInitializer < MiniTest::Unit::TestCase
def test_to_hash
initializer = Initializer.new
hash = initializer.to_hash({mean: 1, std: 2})
expected_hash = {
class: "DNN::Initializers::Initializer",
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/optimizers_test.rb | Ruby | mit | 47 | master | 11,474 | require "test_helper"
class TestOptimizer < MiniTest::Unit::TestCase
def test_to_hash
optimizer = DNN::Optimizers::Optimizer.new
hash = optimizer.to_hash({momentum: 0.9})
expected_hash = {
class: "DNN::Optimizers::Optimizer",
momentum: 0.9,
clip_norm: nil,
}
assert_equal expecte... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/iterator_test.rb | Ruby | mit | 47 | master | 1,727 | require "test_helper"
class TestIterator < MiniTest::Unit::TestCase
def test_next_batch
x_datas = Xumo::Int32.zeros(10, 10)
y_datas = Xumo::Int32.zeros(10, 10)
iter = DNN::Iterator.new(x_datas, y_datas)
iter.next_batch(7)
x, y = iter.next_batch(7)
assert_equal [3, 10], x.shape
assert_equ... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/savers_test.rb | Ruby | mit | 47 | master | 2,410 | require "test_helper"
class TestMarshalSaver < MiniTest::Unit::TestCase
# It is result of load marshal is as expected.
def test_dump_bin
model = DNN::Models::Sequential.new([DNN::Layers::InputLayer.new(10), DNN::Layers::Dense.new(1)])
model.setup(DNN::Optimizers::SGD.new, DNN::Losses::MeanSquaredError.new)... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/functions_test/activations_test.rb | Ruby | mit | 47 | master | 5,840 | require "test_helper"
class TestSigmoid < MiniTest::Unit::TestCase
def test_forward
sigmoid = DNN::Functions::Sigmoid.new
y = sigmoid.forward(Xumo::SFloat[0, 1])
assert_equal Xumo::SFloat[0.5, 0.7311], y.round(4)
end
def test_backward
sigmoid = DNN::Functions::Sigmoid.new
x = Xumo::SFloat[0,... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/functions_test/losses_test.rb | Ruby | mit | 47 | master | 3,566 | require "test_helper"
class TestMeanSquaredError < MiniTest::Unit::TestCase
def test_forward
loss = DNN::Functions::MeanSquaredError.new
y = Xumo::SFloat[[0, 1]]
t = Xumo::SFloat[[2, 4]]
out_y = loss.forward(y, t)
assert_equal 6.5, out_y.round(4)
end
def test_backward
loss = DNN::Functio... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/functions_test/math_test.rb | Ruby | mit | 47 | master | 8,622 | require "test_helper"
class TestMathUtils < MiniTest::Unit::TestCase
def test_align_ndim1
shape1 = [1, 2, 3, 4]
shape2 = [1, 2, 3, 4]
shape1, shape2 = DNN::Functions::MathUtils.align_ndim(shape1, shape2)
assert_equal [1, 2, 3, 4], shape1
assert_equal [1, 2, 3, 4], shape2
end
def test_align_n... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/functions_test/basic_test.rb | Ruby | mit | 47 | master | 6,205 | require "test_helper"
class TestAdd < MiniTest::Unit::TestCase
def test_forward
add = DNN::Functions::Add.new
y = add.forward(Xumo::SFloat[1, 2], Xumo::SFloat[3, 4])
assert_equal Xumo::SFloat[4, 6], y.round(4)
end
def test_backward
add = DNN::Functions::Add.new
add.forward(Xumo::SFloat[1, 2]... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/layers_test/cnn_layers_test.rb | Ruby | mit | 47 | master | 15,454 | require "test_helper"
class TestConv2D_Utils < MiniTest::Unit::TestCase
include DNN::Layers::Conv2DUtils
# im2col test.
def test_im2col
img = Xumo::SFloat.cast([[
[
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16],
],
[
[17, 18, 19, 20],... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/layers_test/normalizations_test.rb | Ruby | mit | 47 | master | 3,352 | require "test_helper"
include DNN::Layers
include DNN::Optimizers
class TestBatchNormalization < MiniTest::Unit::TestCase
def test_from_hash
hash = {
class: "DNN::Layers::BatchNormalization",
axis: 1,
momentum: 0.8,
}
batch_norm = BatchNormalization.from_hash(hash)
assert_equal 1, ... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/layers_test/basic_layers_test.rb | Ruby | mit | 47 | master | 10,663 | require "test_helper"
include DNN::Layers
include DNN::Optimizers
include DNN::Initializers
include DNN::Regularizers
class TestLayer < MiniTest::Unit::TestCase
def test_initialize
layer = Layer.new
assert_equal layer.instance_variable_get(:@built), false
end
def test_build
layer = Layer.new
la... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/layers_test/embedding_test.rb | Ruby | mit | 47 | master | 2,955 | require "test_helper"
include DNN::Layers
include DNN::Optimizers
include DNN::Initializers
include DNN::Regularizers
class TestEmbedding < MiniTest::Unit::TestCase
def test_from_hash
hash = {
class: "DNN::Layers::Embedding",
input_shape: [10],
input_length: 5,
weight_initializer: Random... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/layers_test/activations_test.rb | Ruby | mit | 47 | master | 2,035 | require "test_helper"
class TestSigmoid < MiniTest::Unit::TestCase
def test_forward
sigmoid = DNN::Layers::Sigmoid.new
y = sigmoid.(DNN::Tensor.new(Xumo::SFloat[0, 1]))
assert_equal Xumo::SFloat[0.5, 0.7311], y.data.round(4)
end
end
class TestTanh < MiniTest::Unit::TestCase
def test_forward
tanh... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | test/layers_test/rnn_layers_test.rb | Ruby | mit | 47 | master | 15,044 | require "test_helper"
include DNN::Layers
class TestRNN < MiniTest::Unit::TestCase
def test_initialize
rnn = RNN.new(64, stateful: true, return_sequences: false,
weight_initializer: DNN::Initializers::RandomUniform.new,
recurrent_weight_initializer: DNN::Initializers::RandomU... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn.rb | Ruby | mit | 47 | master | 1,836 | if RUBY_PLATFORM == "wasm32-wasi"
require "narray.so"
else
require "numo/narray"
end
if ENV["RUNY_DNN_USE_NUMO_LINALG"] == "ENABLE"
require "numo/linalg/autoloader"
end
module DNN
if ENV["RUBY_DNN_USE_CUMO"] == "ENABLE"
require "cumo/narray"
Xumo = ::Cumo
else
if defined? ::Cumo
Xumo = ::C... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/image.rb | Ruby | mit | 47 | master | 5,953 | require "numo/narray"
require_relative "../rb_stb_image"
module DNN
module Image
class ImageError < StandardError; end
class ImageReadError < ImageError; end
class ImageWriteError < ImageError; end
class ImageShapeError < ImageError; end
RGB = 3
RGBA = 4
# Read image from file.
#... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/numo2numpy.rb | Ruby | mit | 47 | master | 2,476 | # This library is a performs mutual conversion between Numo and Numpy.
# You need to install PyCall to use this library.
# [Usage]
# numpy to numo: Numpy.to_na(np_array)
# numo to numpy: Numpy.from_na(narray)
require "pycall/import"
require "numpy"
include PyCall::Import
class NumpyToNumoError < StandardError; end
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/keras-model-convertor.rb | Ruby | mit | 47 | master | 8,008 | # This library is not yet complete.
# This library converts keras models to ruby-dnn models.
# Use of the library requires the installation of PyCall.
require "pycall/import"
require "numpy"
require_relative "numo2numpy"
include PyCall::Import
pyimport :keras
module DNN
module Layers
class Softmax < Layer
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/rl/agent.rb | Ruby | mit | 47 | master | 4,608 | module DNN
module RL
class Agent < ProcessRunner
attr_reader :model
attr_reader :env
attr_accessor :gamma
# @param [DNN::Models::Model] model Model used for training.
# @param [RL::Env] env Training environment.
# @param [Integer] max_memory_size Max size of memory for storing... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/rl/dqn_agent.rb | Ruby | mit | 47 | master | 1,445 | module DNN
module RL
class DQNAgent < Agent
def initialize(model, env,
max_memory_size: 1024,
train_memory_size: nil,
batch_size: 64,
gamma: 0.99,
policy: Policies::EpsGreedy.new,
ddqn: tr... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/rl/env.rb | Ruby | mit | 47 | master | 695 | module DNN
module RL
class Env
attr_reader :state_size
attr_reader :action_size
attr_reader :max_step
def initialize(state_size, action_size, max_step)
@state_size = state_size
@action_size = action_size
@max_step = max_step
end
def step
raise ... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/rl/policies.rb | Ruby | mit | 47 | master | 637 | module DNN
module RL
module Policies
class Policy
def predict?(episode)
raise NotImplementedError, "Class '#{self.class.name}' has implement method 'predict?'"
end
end
class EpsGreedy < Policy
def initialize(base_eps: 0.0001, initial_eps: 0.5, decay: 0.9)
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/rl/memory.rb | Ruby | mit | 47 | master | 609 | module DNN
module RL
class Memory
attr_reader :max_size
attr_reader :train_size
def initialize(max_size, train_size)
@max_size = max_size
@train_size = train_size
@memory = []
end
def add(v)
@memory << v
@memory.shift if @memory.size > @max_s... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/evaluator.rb | Ruby | mit | 47 | master | 7,572 | module DNN
module EvaluatorImpl
# Evaluate model and get accuracy and loss of test data.
# @param [Numo::SFloat] x Input test data.
# @param [Numo::SFloat] y Output test data.
# @param [Integer] batch_size Batch size used for one test.
# @param [Boolean] need_accuracy Set true to compute the accur... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/trainer.rb | Ruby | mit | 47 | master | 13,430 | module DNN
module TrainerImpl
# Start training.
# Setup the model before use this method.
# @param [Numo::SFloat] x Input training data.
# @param [Numo::SFloat] y Output training data.
# @param [Integer] epochs Number of training.
# @param [Integer] batch_size Batch size used for one training.... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/monkey_patch.rb | Ruby | mit | 47 | master | 1,573 | class Integer
alias dnn__add +
def +(other)
if other.is_a?(DNN::BaseTensor)
DNN::Functions::Add.(DNN::Tensor.new(self), other)
else
dnn__add(other)
end
end
alias dnn__sub -
def -(other)
if other.is_a?(DNN::BaseTensor)
DNN::Functions::Sub.(DNN::Tensor.new(self), other)
el... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/process_runner.rb | Ruby | mit | 47 | master | 1,084 | module DNN
class ProcessRunner
def initialize
@callbacks = []
@last_logs = {}
end
# Add callback function.
# @param [Callback] callback Callback object.
def add_callback(callback)
callback.runner = self
@callbacks << callback
end
# Add lambda callback.
# @para... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/predictor.rb | Ruby | mit | 47 | master | 5,408 | module DNN
module PredictorImpl
attr_reader :predicted_data
attr_accessor :last_predicted_batch
# Predict model and get accuracy and loss of predict data.
# @param [Numo::SFloat] x Input predict data.
# @param [Integer] batch_size Batch size used for one predict.
# @return [Array] Returns the... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/initializers.rb | Ruby | mit | 47 | master | 3,847 | module DNN
module Initializers
class Initializer
def self.from_hash(hash)
return nil unless hash
initializer_class = DNN.const_get(hash[:class])
initializer = initializer_class.allocate
raise DNNError, "#{initializer.class} is not an instance of #{self} class." unless initia... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/losses.rb | Ruby | mit | 47 | master | 2,341 | module DNN
module Losses
class Loss
def self.call(y, t, *args, **kwargs)
new(*args, **kwargs).(y, t)
end
def self.from_hash(hash)
return nil unless hash
loss_class = DNN.const_get(hash[:class])
loss = loss_class.allocate
raise DNNError, "#{loss.class} is... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/progress_bar.rb | Ruby | mit | 47 | master | 833 | class ProgressBar
def initialize(max_size, length: 40, io: $stdout)
@max_size = max_size
@length = length
@io = io
@current_size = 0
end
def progress(size)
if @current_size + size > @max_size
@current_size = @max_size
else
@current_size += size
end
end
def print(prepa... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/tensor.rb | Ruby | mit | 47 | master | 552 | module DNN
class Tensor < BaseTensor
attr_reader :prev_link
def self.convert(inputs)
inputs.is_a?(Array) ? inputs.map { |input| self.new(input) } : self.new(inputs)
end
def initialize(data, prev_link: nil, backward_index: nil)
super(data)
@prev_link = prev_link
@backward_inde... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/regularizers.rb | Ruby | mit | 47 | master | 2,577 | module DNN
module Regularizers
class Regularizer
attr_accessor :param
def self.from_hash(hash)
return nil unless hash
regularizer_class = DNN.const_get(hash[:class])
regularizer = regularizer_class.allocate
raise DNNError, "#{regularizer.class} is not an instance of #... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/savers.rb | Ruby | mit | 47 | master | 3,370 | require "zlib"
require "json"
require "base64"
module DNN
module Loaders
class Loader
def initialize(model)
@model = model
end
def load(file_name)
load_bin(File.binread(file_name))
end
def load_bin(bin)
raise NotImplementedError, "Class '#{self.class.name}... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions.rb | Ruby | mit | 47 | master | 1,471 | module DNN
module Functions
class Function
def self.call(*inputs)
new.(*inputs)
end
def call(*inputs)
xs = inputs.map(&:data)
ys = forward(*xs)
num_outputs = (ys.is_a?(Array) ? ys.length : 1)
if inputs.find { |prev| prev && prev.requires_grad }
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/iterator.rb | Ruby | mit | 47 | master | 3,633 | module DNN
# Super class of all iterators.
class BaseIterator
attr_reader :num_datas
attr_reader :last_round_down
# @param [Boolean] last_round_down Set true to round down for last batch data when call foreach.
def initialize(last_round_down: false)
@last_round_down = last_round_down
@h... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/callbacks.rb | Ruby | mit | 47 | master | 4,757 | module DNN
module Callbacks
class Callback
attr_accessor :runner
# Please implement the method used for callback event.
# Process performed before all training.
# def before_train; end
# Process performed after all training.
# def after_train; end
# Process performed... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/link.rb | Ruby | mit | 47 | master | 1,546 | module DNN
class Link
attr_reader :prevs
attr_reader :node
attr_reader :num_outputs
def initialize(prevs: nil, node: nil, num_outputs: 1)
@prevs = prevs
@node = node
@num_outputs = num_outputs
@hold_datas = []
@held_flags = []
@requires_grad = nil
end
def ... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/optimizers.rb | Ruby | mit | 47 | master | 11,431 | module DNN
module Optimizers
# Super class of all optimizer classes.
class Optimizer
attr_reader :status
attr_accessor :clip_norm
def self.from_hash(hash)
return nil unless hash
optimizer_class = DNN.const_get(hash[:class])
optimizer = optimizer_class.allocate
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/base_tensor.rb | Ruby | mit | 47 | master | 2,697 | module DNN
class BaseTensor
attr_reader :data
attr_reader :next_links
def initialize(data)
if data.is_a?(Integer)
@data = Xumo::Int32[data]
elsif data.is_a?(Float)
@data = Xumo::SFloat[data]
elsif data.is_a?(Tensor)
@data = data.data
else
@data = da... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/models.rb | Ruby | mit | 47 | master | 16,754 | module DNN
module Models
# This class is used to hold multiple layers in an array.
class LayerList < Array
def self.from_hash_list(hash_list)
layers_list = new
hash_list.each do |hash|
obj_class = DNN.const_get(hash[:class])
obj = obj_class.allocate
if obj.... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/variable.rb | Ruby | mit | 47 | master | 1,065 | module DNN
class Variable < BaseTensor
attr_accessor :requires_grad
attr_accessor :grad
attr_writer :data
def initialize(*args, requires_grad: true)
if args.length == 0
data = nil
grad = nil
elsif args.length == 1
data = args[0]
grad = nil
elsif args.... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/utils.rb | Ruby | mit | 47 | master | 2,141 | module DNN
# This module provides utility functions.
module Utils
# Categorize labels into "num_classes" classes.
# @param [Numo::SFloat] y Label data.
# @param [Numo::SFloat] num_classes Number of classes to classify.
# @param [Class] narray_type Type of Numo::Narray data after classification.
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/embedding.rb | Ruby | mit | 47 | master | 957 | module DNN
module Functions
class Embedding < Function
def initialize(mask_zero)
@mask_zero = mask_zero
end
def forward(x, weight)
@x = x
@weight = weight
y = Xumo::SFloat.zeros(*x.shape)
x.shape[0].times do |i|
if @mask_zero
x.shap... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/basic.rb | Ruby | mit | 47 | master | 6,178 | module DNN
module Functions
class Add < Function
def initialize
@requires_dx1 = true
@requires_dx2 = true
end
def call(x1, x2)
@requires_dx1 = x1.requires_grad
@requires_dx2 = x2.requires_grad
super(x1, x2)
end
def forward(x1, x2)
@x1... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/cnn.rb | Ruby | mit | 47 | master | 10,034 | module DNN
module Functions
module Conv2DFunctionUtils
module_function
# img[bsize, out_h, out_w, ch] to col[bsize * out_h * out_w, fil_h * fil_w * ch]
def im2col(*args)
if DNN.use_cumo?
im2col_gpu(*args)
else
im2col_cpu(*args)
end
end
#... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/math.rb | Ruby | mit | 47 | master | 4,916 | module DNN
module Functions
module MathUtils
module_function
def align_ndim(shape1, shape2)
shape1 = shape1.clone
shape2 = shape2.clone
if shape1.length < shape2.length
shape2.length.times do |axis|
unless shape1[axis] == shape2[axis]
shape1... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/dropout.rb | Ruby | mit | 47 | master | 788 | module DNN
module Functions
class Dropout < Function
def initialize(dropout_ratio = 0.5, seed: rand(1 << 31), use_scale: true, learning_phase: false)
super()
@dropout_ratio = dropout_ratio
@seed = seed
@use_scale = use_scale
@learning_phase = learning_phase
@m... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/rnn.rb | Ruby | mit | 47 | master | 7,245 | module DNN
module Functions
class RNNTimeSplit < Function
def forward(xs)
@xs_shape = xs.shape
y_outputs = []
xs.shape[1].times do |t|
y_outputs << xs[true, t, false]
end
y_outputs
end
def backward(*dy_inputs)
dxs = Xumo::SFloat.zeros(@x... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/losses.rb | Ruby | mit | 47 | master | 2,634 | module DNN
module Functions
class MeanSquaredError < Function
def forward(y, t)
@y = y
@t = t
0.5 * ((y - t)**2).mean(0).sum
end
def backward(d)
d * (@y - @t) / @y.shape[0]
end
end
class MeanAbsoluteError < Function
def forward(y, t)
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/normalizations.rb | Ruby | mit | 47 | master | 1,595 | module DNN
module Functions
class BatchNormalization < Function
attr_reader :running_mean
attr_reader :running_var
def initialize(running_mean, running_var, axis: 0, momentum: 0.9, eps: 1e-7, learning_phase: false)
super()
@running_mean = running_mean
@running_var = run... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/functions/activations.rb | Ruby | mit | 47 | master | 4,245 | module DNN
module Functions
class Sigmoid < Function
def forward(x)
@y = 1 / (1 + Xumo::NMath.exp(-x))
end
def backward(dy)
dy * (1 - @y) * @y
end
end
class Tanh < Function
def forward(x)
@y = Xumo::NMath.tanh(x)
end
def backward(dy)
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/layers/normalizations.rb | Ruby | mit | 47 | master | 2,174 | module DNN
module Layers
class BatchNormalization < Layer
attr_reader :gamma
attr_reader :beta
attr_reader :running_mean
attr_reader :running_var
attr_reader :axis
attr_accessor :momentum
attr_accessor :eps
# @param [Integer] axis The axis to normalization.
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/layers/embedding.rb | Ruby | mit | 47 | master | 2,449 | module DNN
module Layers
class Embedding < Layer
attr_reader :input_length
attr_reader :weight
attr_reader :weight_initializer
attr_reader :weight_regularizer
attr_reader :mask_zero
# @param [Integer | Array] input_dim_or_shape Set input data dimension or shape.
# @para... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/layers/cnn_layers.rb | Ruby | mit | 47 | master | 17,428 | module DNN
module Layers
# This module is used for convolution.
module Conv2DUtils
module_function
# img[bsize, out_h, out_w, ch] to col[bsize * out_h * out_w, fil_h * fil_w * ch]
def im2col(*args)
if DNN.use_cumo?
im2col_gpu(*args)
else
im2col_cpu(*args... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/layers/rnn_layers.rb | Ruby | mit | 47 | master | 12,668 | module DNN
module Layers
class SimpleRNNCell < Layer
def forward(x, h, weight, recurrent_weight, bias = nil)
h2 = x.dot(weight) + h.dot(recurrent_weight)
h2 += bias if bias
h2
end
end
class LSTMCell < Layer
def forward(x, h, c, weight, recurrent_weight, bias = ni... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/layers/basic_layers.rb | Ruby | mit | 47 | master | 9,858 | module DNN
module Layers
# Super class of all layer classes.
class Layer
attr_reader :input_shapes
def self.from_hash(hash)
return nil unless hash
layer_class = DNN.const_get(hash[:class])
layer = layer_class.allocate
raise DNNError, "#{layer.class} is not an inst... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/core/layers/activations.rb | Ruby | mit | 47 | master | 1,661 | module DNN
module Layers
class Sigmoid < Layer
def forward(x)
Functions::FunctionSpace.sigmoid(x)
end
end
class Tanh < Layer
def forward(x)
Functions::FunctionSpace.tanh(x)
end
end
class Softsign < Layer
def forward(x)
Functions::FunctionSpa... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/datasets/iris.rb | Ruby | mit | 47 | master | 1,774 | require "csv"
require_relative "downloader"
module DNN
class DNN_Iris_LoadError < DNNError; end
module Iris
URL_CSV = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
# Iris-setosa
SETOSA = 0
# Iris-versicolor
VERSICOLOR = 1
# Iris-virginica
VIRGINICA = 2
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/datasets/mnist.rb | Ruby | mit | 47 | master | 3,224 | require "zlib"
require_relative "../core/error"
require_relative "downloader"
module DNN
module MNIST
class DNN_MNIST_LoadError < DNNError; end
URL_BASE = "http://yann.lecun.com/exdb/mnist/"
TRAIN_IMAGES_FILE_NAME = "train-images-idx3-ubyte.gz"
TRAIN_LABELS_FILE_NAME = "train-labels-idx1-ubyte.gz"
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/datasets/cifar10.rb | Ruby | mit | 47 | master | 1,772 | require "zlib"
require "archive/tar/minitar"
require_relative "downloader"
URL_CIFAR10 = "https://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz"
DIR_CIFAR10 = "cifar-10-batches-bin"
module DNN
module CIFAR10
class DNN_CIFAR10_LoadError < DNNError; end
def self.downloads
return if Dir.exist?(DOWNLOA... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/datasets/cifar100.rb | Ruby | mit | 47 | master | 1,734 | require "zlib"
require "archive/tar/minitar"
require_relative "downloader"
URL_CIFAR100 = "https://www.cs.toronto.edu/~kriz/cifar-100-binary.tar.gz"
DIR_CIFAR100 = "cifar-100-binary"
module DNN
module CIFAR100
class DNN_CIFAR100_LoadError < DNNError; end
def self.downloads
return if Dir.exist?(DOWNLO... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/datasets/fashion-mnist.rb | Ruby | mit | 47 | master | 3,290 | require "zlib"
require_relative "../core/error"
require_relative "downloader"
require_relative "mnist"
module DNN
module FashionMNIST
class DNN_MNIST_LoadError < DNNError; end
URL_BASE = "http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/"
TRAIN_IMAGES_FILE_NAME = "train-images-idx3-ubyte.gz"
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/datasets/stl-10.rb | Ruby | mit | 47 | master | 2,605 | require "zlib"
require "archive/tar/minitar"
require_relative "downloader"
URL_STL10 = "http://ai.stanford.edu/~acoates/stl10/stl10_binary.tar.gz"
DIR_STL10 = "stl10_binary"
module DNN
module STL10
class DNN_STL10_LoadError < DNNError; end
def self.downloads
return if Dir.exist?(DOWNLOADS_PATH + "/do... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | lib/dnn/datasets/downloader.rb | Ruby | mit | 47 | master | 1,405 | require "net/https"
module DNN
DOWNLOADS_PATH = ENV["RUBY_DNN_DOWNLOADS_PATH"] || __dir__
class DNN_DownloadError < DNNError; end
class Downloader
def self.download(url, dir_path = nil)
unless dir_path
Dir.mkdir("#{DOWNLOADS_PATH}/downloads") unless Dir.exist?("#{DOWNLOADS_PATH}/downloads")
... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/mnist_conv2d_example.rb | Ruby | mit | 47 | master | 1,068 | require "dnn"
require "dnn/datasets/mnist"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x_train, y_train = DNN::MNIST.load_train
x_test, y_test = DNN::MNIST.load_test
x_train = Numo::SFloat.cast(x_train) / 255
x_test = Numo::SFloat.cast(x_test) / 255
y_train = DNN::Utils.to_ca... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/mnist_define_by_run.rb | Ruby | mit | 47 | master | 1,062 | require "dnn"
require "dnn/datasets/mnist"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x_train, y_train = DNN::MNIST.load_train
x_test, y_test = DNN::MNIST.load_test
x_train = x_train.reshape(x_train.shape[0], 784)
x_test = x_test.reshape(x_test.shape[0], 784)
x_train = Numo:... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/vae.rb | Ruby | mit | 47 | master | 2,228 | require "dnn"
require "dnn/datasets/mnist"
require "dnn/image"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x_train, * = DNN::MNIST.load_train
x_train = Numo::SFloat.cast(x_train).reshape(x_train.shape[0], 784)
x_train /= 255
$z_dim = 2
$z_mean = nil
$z_sigma = nil
class Enc... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/xor_example.rb | Ruby | mit | 47 | master | 459 | 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.ne... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/cifar100_example.rb | Ruby | mit | 47 | master | 1,468 | require "dnn"
require "dnn/datasets/cifar100"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x_train, y_train = DNN::CIFAR100.load_train
x_test, y_test = DNN::CIFAR100.load_test
x_train = Numo::SFloat.cast(x_train) / 255
x_test = Numo::SFloat.cast(x_test) / 255
y_train = DNN::Ut... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/iris_example_unused_model.rb | Ruby | mit | 47 | master | 1,450 | require "dnn"
require "dnn/datasets/iris"
include DNN::Layers
include DNN::Optimizers
Fs = DNN::Functions::FunctionSpace
x, y = DNN::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 ... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/iris_example.rb | Ruby | mit | 47 | master | 756 | require "dnn"
require "dnn/datasets/iris"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x, y = DNN::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_t... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/mnist_gpu.rb | Ruby | mit | 47 | master | 1,144 | require "cumo/narray"
require "dnn"
require "dnn/datasets/mnist"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x_train, y_train = DNN::MNIST.load_train
x_test, y_test = DNN::MNIST.load_test
x_train = x_train.reshape(x_train.shape[0], 784)
x_test = x_test.reshape(x_test.shape[0],... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/cifar10_example.rb | Ruby | mit | 47 | master | 1,462 | require "dnn"
require "dnn/datasets/cifar10"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x_train, y_train = DNN::CIFAR10.load_train
x_test, y_test = DNN::CIFAR10.load_test
x_train = Numo::SFloat.cast(x_train) / 255
x_test = Numo::SFloat.cast(x_test) / 255
y_train = DNN::Utils... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/mnist_lstm_example.rb | Ruby | mit | 47 | master | 933 | require "dnn"
require "dnn/datasets/mnist"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x_train, y_train = DNN::MNIST.load_train
x_test, y_test = DNN::MNIST.load_test
x_train = x_train.reshape(x_train.shape[0], 28, 28)
x_test = x_test.reshape(x_test.shape[0], 28, 28)
x_train =... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/mnist_example.rb | Ruby | mit | 47 | master | 936 | require "dnn"
require "dnn/datasets/mnist"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
x_train, y_train = DNN::MNIST.load_train
x_test, y_test = DNN::MNIST.load_test
x_train = x_train.reshape(x_train.shape[0], 784)
x_test = x_test.reshape(x_test.shape[0], 784)
x_train = Numo:... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/api-examples/save_example.rb | Ruby | mit | 47 | master | 2,278 | require "dnn"
require "dnn/datasets/mnist"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
include DNN::Savers
include DNN::Loaders
USE_MARSHAL = 0
USE_JSON = 1
EPOCHS = 3
BATCH_SIZE = 128
# Select save style from USE_MARSHAL or USE_JSON.
SAVE_STYLE = USE_MARSHAL
# When set a tr... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/api-examples/regularizer_example.rb | Ruby | mit | 47 | master | 1,489 | require "dnn"
require "dnn/datasets/mnist"
include DNN::Models
include DNN::Layers
include DNN::Regularizers
include DNN::Optimizers
include DNN::Losses
EPOCHS = 3
BATCH_SIZE = 128
L2_LAMBDA = 0.01
x_train, y_train = DNN::MNIST.load_train
x_test, y_test = DNN::MNIST.load_test
x_train = x_train.reshape(x_train.shape... |
github | unagiootoro/ruby-dnn | https://github.com/unagiootoro/ruby-dnn | examples/api-examples/early_stopping_example.rb | Ruby | mit | 47 | master | 1,356 | require "dnn"
require "dnn/datasets/mnist"
include DNN::Models
include DNN::Layers
include DNN::Optimizers
include DNN::Losses
include DNN::Callbacks
EPOCHS = 3
BATCH_SIZE = 128
x_train, y_train = DNN::MNIST.load_train
x_test, y_test = DNN::MNIST.load_test
x_train = x_train.reshape(x_train.shape[0], 784)
x_test = x... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.