ruby-dnn 1.2.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8475052a51f8b81f176c8b3a77c953d116fb1098b7f24fe8a2ad9135b2f2a33b
4
- data.tar.gz: f291c99be16b9a35fee59a09cefda3b9aece1bbaef5d6b482fad6d238043e68b
3
+ metadata.gz: 0155251f4bb07fe6ed61f27102f8ef9b251fcc2cfba72fafaab7819072c28e69
4
+ data.tar.gz: 8fce285715f424cf5d78f38c81b0d653e281cd21ebaa04702e1cd38ce2de6c2b
5
5
  SHA512:
6
- metadata.gz: '08f061510f73297b12b53cd3da5748dd47e67605d1b40c35388779a94e023e37450d2c9ebd9ec1bf0970c1580c7481f46c6cef05d54af5748fe175522b198c5e'
7
- data.tar.gz: fdfe99ac9b5a63e4914aaab4f71a37e56b097c6b00560245a82438c6fd70ab658683de95c1ddef0283f4cc2f0b9e261dda798158cd374cf19cc17966ed338b16
6
+ metadata.gz: b1ec453443c1713323263b0d6b9086eca1978bd6ed9102956cc4ad6098b2698248eedced6851fbf0d2d49223277eff369532e96a53c6df8351b016fdc22830f4
7
+ data.tar.gz: 8f41bf55e995854dfa96159197a40bf1f0e50f5cbf99eee97d835986e4aeef366ddd777ddbbe82514de22a048ca34600107bb59cbc0a2f58c7e3d5f8f1d06dd4
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.lock
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.6.1
4
+ - 2.6
5
+ - 2.7
5
6
  script:
6
7
  - rake test
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # ruby-dnn
2
- [![Gem Version](https://badge.fury.io/rb/ruby-dnn.svg)](https://badge.fury.io/rb/ruby-dnn)
2
+ [![Gem Version](https://badge.fury.io/rb/ruby-dnn.svg)](https://badge.fury.io/rb/ruby-dnn)
3
3
  [![Build Status](https://travis-ci.org/unagiootoro/ruby-dnn.svg?branch=master)](https://travis-ci.org/unagiootoro/ruby-dnn)
4
+ [![Docs Latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://rubydoc.info/gems/ruby-dnn)
4
5
 
5
6
  ruby-dnn is a ruby deep learning library. This library supports full connected neural network and convolution neural network
6
7
  and recurrent neural network.
@@ -84,6 +85,23 @@ puts "loss: #{loss}"
84
85
  Please refer to examples for basic usage.
85
86
  If you want to know more detailed information, please refer to the source code.
86
87
 
88
+ ## Sample
89
+
90
+ * Pix2pix
91
+ Convert an abstract image into a building image.
92
+ [https://github.com/unagiootoro/facade-pix2pix](https://github.com/unagiootoro/facade-pix2pix)
93
+ ![facade-pix2pix.png](img/facade-pix2pix.png)
94
+
95
+ * Cycle-GAN
96
+ Convert apples to oranges and oranges to apples.
97
+ [https://github.com/unagiootoro/apple2orange-cyclegan](https://github.com/unagiootoro/apple2orange-cyclegan)
98
+ ![cycle-gan.PNG](img/cycle-gan.PNG)
99
+
100
+ * DQN
101
+ Learn the game so that the pole on the cart does not fall.
102
+ [https://github.com/unagiootoro/ruby-rl](https://github.com/unagiootoro/ruby-rl)
103
+ ![cart-pole.gif](img/cart-pole.gif)
104
+
87
105
  ## Implemented
88
106
  || Implemented classes |
89
107
  |:-----------|------------:|
@@ -95,32 +113,27 @@ If you want to know more detailed information, please refer to the source code.
95
113
  | Losses | MeanSquaredError, MeanAbsoluteError, Hinge, HuberLoss, SoftmaxCrossEntropy, SigmoidCrossEntropy |
96
114
 
97
115
  ## Datasets
98
- By setting the environment variable 'RUBY_DNN_DOWNLOADS_PATH', you can specify the path to read dataset.
99
-
100
- ● Iris
101
- ● MNIST
102
- ● Fashion-MNIST
103
- ● CIFAR-10
104
- ● CIFAR-100
105
- ● STL-10
116
+ By setting the environment variable `RUBY_DNN_DOWNLOADS_PATH`, you can specify the path to read dataset.
106
117
 
107
- ## Examples
108
- VAE
109
- DCGAN
110
- Pix2pix
118
+ * Iris
119
+ * MNIST
120
+ * Fashion-MNIST
121
+ * CIFAR-10
122
+ * CIFAR-100
123
+ * STL-10
111
124
 
112
125
  ## Use GPU
113
- If you do 'require "cumo/narray"' before 'require "dnn"', you can run it on GPU.
114
- Or, set the environment variable 'RUBY_DNN_USE_CUMO 'to'ENABLE' to force the GPU to be used.
126
+ If you do `require "cumo/narray"` before `require "dnn"`, you can run it on GPU.
127
+ Or, set the environment variable `RUBY_DNN_USE_CUMO` to `ENABLE` to force the GPU to be used.
115
128
 
116
129
  ## TODO
117
- Write a test.
118
- Write a document.
119
- Improve performance when using GPU.
130
+ * Write a test.
131
+ * Write a document.
132
+ * Improve performance when using GPU.
120
133
 
121
134
  ## Development
122
135
 
123
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake "spec"` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
136
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake "test"` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
124
137
 
125
138
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
126
139
 
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
+ require "rake/extensiontask"
3
4
  require "yard"
4
5
  require "yard/rake/yardoc_task"
5
6
 
@@ -10,6 +11,10 @@ Rake::TestTask.new(:test) do |t|
10
11
  t.test_files = FileList["test/*_test.rb", "test/layers_test/*_test.rb"]
11
12
  end
12
13
 
14
+ Rake::ExtensionTask.new "rb_stb_image" do |ext|
15
+ ext.lib_dir = "lib/rb_stb_image"
16
+ end
17
+
13
18
  task :build_rb_stb_image do
14
19
  sh "cd ext/rb_stb_image; ruby extconf.rb; make"
15
20
  end
@@ -129,7 +129,7 @@ class DCGAN < Model
129
129
  y_fake = Numo::SFloat.zeros(batch_size, 1)
130
130
  @dis.enable_training
131
131
  dis_loss = @dis.train_on_batch(x_batch, y_real)
132
- dis_loss + @dis.train_on_batch(images, y_fake)
132
+ dis_loss += @dis.train_on_batch(images, y_fake)
133
133
 
134
134
  noise = Numo::SFloat.new(batch_size, 20).rand(-1, 1)
135
135
  label = Numo::SFloat.cast([1] * batch_size).reshape(batch_size, 1)
data/img/cart-pole.gif ADDED
Binary file
data/img/cycle-gan.PNG ADDED
Binary file
Binary file
@@ -26,8 +26,8 @@ module DNN
26
26
  attr_reader :input_shape
27
27
  attr_reader :output_shape
28
28
 
29
- def self.call(x, *args)
30
- new(*args).(x)
29
+ def self.call(x, *args, **kwargs)
30
+ new(*args, **kwargs).(x)
31
31
  end
32
32
 
33
33
  def self.from_hash(hash)
@@ -2,8 +2,8 @@ module DNN
2
2
  module Layers
3
3
 
4
4
  class MergeLayer < Layer
5
- def self.call(x1, x2, *args)
6
- new(*args).call(x1, x2)
5
+ def self.call(x1, x2, *args, **kwargs)
6
+ new(*args, **kwargs).call(x1, x2)
7
7
  end
8
8
 
9
9
  def call(input1, input2)
@@ -2,8 +2,8 @@ module DNN
2
2
  module Losses
3
3
 
4
4
  class Loss
5
- def self.call(y, t, *args)
6
- new(*args).(y, t)
5
+ def self.call(y, t, *args, **kwargs)
6
+ new(*args, **kwargs).(y, t)
7
7
  end
8
8
 
9
9
  def self.from_hash(hash)
@@ -1,4 +1,4 @@
1
- require "net/http"
1
+ require "net/https"
2
2
 
3
3
  module DNN
4
4
  DOWNLOADS_PATH = ENV["RUBY_DNN_DOWNLOADS_PATH"] || __dir__
@@ -18,13 +18,22 @@ module DNN
18
18
 
19
19
  def initialize(url)
20
20
  @url = url
21
- *, @fqdn, @path = *url.match(%r`https?://(.+?)(/.+)`)
21
+ *, @protocol, @fqdn, @path = *url.match(%r`(https?)://(.+?)(/.+)`)
22
22
  end
23
23
 
24
24
  def download(dir_path)
25
25
  puts %`download "#{@url}"`
26
26
  buf = ""
27
- Net::HTTP.start(@fqdn) do |http|
27
+ if @protocol == "http"
28
+ port = 80
29
+ elsif @protocol == "https"
30
+ port = 443
31
+ else
32
+ raise "Protocol(#{@protocol}) is not supported."
33
+ end
34
+ http = Net::HTTP.new(@fqdn, port)
35
+ http.use_ssl = true if @protocol == "https"
36
+ http.start do |http|
28
37
  content_length = http.head(@path).content_length
29
38
  http.get(@path) do |body_segment|
30
39
  buf << body_segment
data/lib/dnn/image.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "numo/narray"
2
- require_relative "../../ext/rb_stb_image/rb_stb_image"
2
+ require_relative "../rb_stb_image"
3
3
 
4
4
  module DNN
5
5
  module Image
data/lib/dnn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DNN
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.3"
3
3
  end
data/ruby-dnn.gemspec CHANGED
@@ -17,21 +17,8 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.add_dependency "numo-narray"
19
19
  spec.add_dependency "archive-tar-minitar"
20
- spec.add_dependency "yard"
20
+ spec.add_development_dependency "rake-compiler"
21
21
 
22
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
23
- # to allow pushing to a single host or delete this section to allow pushing to any host.7
24
- =begin
25
- if spec.respond_to?(:metadata)
26
- spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
27
- else
28
- raise "RubyGems 2.0 or newer is required to protect against " \
29
- "public gem pushes."
30
- end
31
- =end
32
-
33
- # Specify which files should be added to the gem when it is released.
34
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
35
22
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
36
23
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
37
24
  end
@@ -39,7 +26,8 @@ Gem::Specification.new do |spec|
39
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
40
27
  spec.require_paths = ["lib"]
41
28
 
42
- spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "bundler", ">= 1.16", "<3.0"
43
30
  spec.add_development_dependency "rake", ">= 12.3.3"
44
31
  spec.add_development_dependency "minitest", "~> 5.0"
32
+ spec.add_development_dependency "yard"
45
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-dnn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - unagiootoro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-24 00:00:00.000000000 Z
11
+ date: 2023-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -39,13 +39,13 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: yard
42
+ name: rake-compiler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :runtime
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -56,16 +56,22 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.16'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '3.0'
62
65
  type: :development
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - "~>"
69
+ - - ">="
67
70
  - !ruby/object:Gem::Version
68
71
  version: '1.16'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rake
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +100,20 @@ dependencies:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
102
  version: '5.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: yard
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
97
117
  description: ruby-dnn is a ruby deep learning library.
98
118
  email:
99
119
  - ootoro838861@outlook.jp
@@ -109,8 +129,6 @@ files:
109
129
  - LICENSE.txt
110
130
  - README.md
111
131
  - Rakefile
112
- - bin/console
113
- - bin/setup
114
132
  - examples/api-examples/early_stopping_example.rb
115
133
  - examples/api-examples/initializer_example.rb
116
134
  - examples/api-examples/regularizer_example.rb
@@ -144,6 +162,9 @@ files:
144
162
  - examples/xor_example.rb
145
163
  - ext/rb_stb_image/extconf.rb
146
164
  - ext/rb_stb_image/rb_stb_image.c
165
+ - img/cart-pole.gif
166
+ - img/cycle-gan.PNG
167
+ - img/facade-pix2pix.png
147
168
  - lib/dnn.rb
148
169
  - lib/dnn/core/callbacks.rb
149
170
  - lib/dnn/core/error.rb
@@ -188,7 +209,7 @@ homepage: https://github.com/unagiootoro/ruby-dnn.git
188
209
  licenses:
189
210
  - MIT
190
211
  metadata: {}
191
- post_install_message:
212
+ post_install_message:
192
213
  rdoc_options: []
193
214
  require_paths:
194
215
  - lib
@@ -203,8 +224,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
224
  - !ruby/object:Gem::Version
204
225
  version: '0'
205
226
  requirements: []
206
- rubygems_version: 3.0.3
207
- signing_key:
227
+ rubygems_version: 3.2.33
228
+ signing_key:
208
229
  specification_version: 4
209
230
  summary: ruby deep learning library.
210
231
  test_files: []
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "dnn"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here