ruby-dnn 0.13.3 → 0.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dnn/core/models.rb +4 -1
- data/lib/dnn/datasets/cifar10.rb +5 -5
- data/lib/dnn/datasets/cifar100.rb +5 -5
- data/lib/dnn/datasets/downloader.rb +7 -2
- data/lib/dnn/datasets/fashion-mnist.rb +2 -2
- data/lib/dnn/datasets/iris.rb +1 -1
- data/lib/dnn/datasets/mnist.rb +2 -2
- data/lib/dnn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfe06541a0afe5fd3465839f02865efe7105c7635003840f60fd46e2976b0c26
|
4
|
+
data.tar.gz: d0f2150f86fe1ee423231c410af8809cecf9d412ecefebb0a3bee1ea14abeee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ad242e2647f2035409432b6568a72d73b95a10b096d863938f9e0cef3bc07aac9a770a9d900d021af2afc3f912a9a3ed4725ba6488411c758b5f5a717a8964
|
7
|
+
data.tar.gz: d4102ded5ade667087736ecea6f897f1136b138682c93a53869e68b3fa70683a3bc8570e3ef3eb840c0a5f13ceb38a7f41b6c9a6f6b4d9bee9543b52ead2a95a
|
data/lib/dnn/core/models.rb
CHANGED
@@ -8,9 +8,12 @@ module DNN
|
|
8
8
|
|
9
9
|
# Load marshal model.
|
10
10
|
# @param [String] file_name File name of marshal model to load.
|
11
|
+
# @return [DNN::Models::Model] Return the loaded model.
|
11
12
|
def self.load(file_name)
|
12
|
-
|
13
|
+
model = self.new
|
14
|
+
loader = Loaders::MarshalLoader.new(model)
|
13
15
|
loader.load(file_name)
|
16
|
+
model
|
14
17
|
end
|
15
18
|
|
16
19
|
def initialize
|
data/lib/dnn/datasets/cifar10.rb
CHANGED
@@ -11,12 +11,12 @@ module DNN
|
|
11
11
|
class DNN_CIFAR10_LoadError < DNN_Error; end
|
12
12
|
|
13
13
|
def self.downloads
|
14
|
-
return if Dir.exist?(
|
14
|
+
return if Dir.exist?(DOWNLOADS_PATH + "/downloads/" + DIR_CIFAR10)
|
15
15
|
Downloader.download(URL_CIFAR10)
|
16
|
-
cifar10_binary_file_name =
|
16
|
+
cifar10_binary_file_name = DOWNLOADS_PATH + "/downloads/" + URL_CIFAR10.match(%r`.+/(.+)`)[1]
|
17
17
|
begin
|
18
18
|
Zlib::GzipReader.open(cifar10_binary_file_name) do |gz|
|
19
|
-
Archive::Tar::Minitar.unpack(gz,
|
19
|
+
Archive::Tar::Minitar.unpack(gz, DOWNLOADS_PATH + "/downloads")
|
20
20
|
end
|
21
21
|
ensure
|
22
22
|
File.unlink(cifar10_binary_file_name)
|
@@ -27,7 +27,7 @@ module DNN
|
|
27
27
|
downloads
|
28
28
|
bin = ""
|
29
29
|
(1..5).each do |i|
|
30
|
-
fname =
|
30
|
+
fname = DOWNLOADS_PATH + "/downloads/#{DIR_CIFAR10}/data_batch_#{i}.bin"
|
31
31
|
raise DNN_CIFAR10_LoadError.new(%`file "#{fname}" is not found.`) unless File.exist?(fname)
|
32
32
|
bin << File.binread(fname)
|
33
33
|
end
|
@@ -39,7 +39,7 @@ module DNN
|
|
39
39
|
|
40
40
|
def self.load_test
|
41
41
|
downloads
|
42
|
-
fname =
|
42
|
+
fname = DOWNLOADS_PATH + "/downloads/#{DIR_CIFAR10}/test_batch.bin"
|
43
43
|
raise DNN_CIFAR10_LoadError.new(%`file "#{fname}" is not found.`) unless File.exist?(fname)
|
44
44
|
bin = File.binread(fname)
|
45
45
|
x_bin, y_bin = CIFAR10.load_binary(bin, 10000)
|
@@ -11,12 +11,12 @@ module DNN
|
|
11
11
|
class DNN_CIFAR100_LoadError < DNN_Error; end
|
12
12
|
|
13
13
|
def self.downloads
|
14
|
-
return if Dir.exist?(
|
14
|
+
return if Dir.exist?(DOWNLOADS_PATH + "/downloads/" + DIR_CIFAR100)
|
15
15
|
Downloader.download(URL_CIFAR100)
|
16
|
-
cifar100_binary_file_name =
|
16
|
+
cifar100_binary_file_name = DOWNLOADS_PATH + "/downloads/" + URL_CIFAR100.match(%r`.+/(.+)`)[1]
|
17
17
|
begin
|
18
18
|
Zlib::GzipReader.open(cifar100_binary_file_name) do |gz|
|
19
|
-
Archive::Tar::Minitar.unpack(gz,
|
19
|
+
Archive::Tar::Minitar.unpack(gz, DOWNLOADS_PATH + "/downloads")
|
20
20
|
end
|
21
21
|
ensure
|
22
22
|
File.unlink(cifar100_binary_file_name)
|
@@ -26,7 +26,7 @@ module DNN
|
|
26
26
|
def self.load_train
|
27
27
|
downloads
|
28
28
|
bin = ""
|
29
|
-
fname =
|
29
|
+
fname = DOWNLOADS_PATH + "/downloads/#{DIR_CIFAR100}/train.bin"
|
30
30
|
raise DNN_CIFAR100_LoadError.new(%`file "#{fname}" is not found.`) unless File.exist?(fname)
|
31
31
|
bin << File.binread(fname)
|
32
32
|
x_bin, y_bin = CIFAR100.load_binary(bin, 50000)
|
@@ -37,7 +37,7 @@ module DNN
|
|
37
37
|
|
38
38
|
def self.load_test
|
39
39
|
downloads
|
40
|
-
fname =
|
40
|
+
fname = DOWNLOADS_PATH + "/downloads/#{DIR_CIFAR100}/test.bin"
|
41
41
|
raise DNN_CIFAR100_LoadError.new(%`file "#{fname}" is not found.`) unless File.exist?(fname)
|
42
42
|
bin = File.binread(fname)
|
43
43
|
x_bin, y_bin = CIFAR100.load_binary(bin, 10000)
|
@@ -1,14 +1,19 @@
|
|
1
1
|
require "net/http"
|
2
2
|
|
3
3
|
module DNN
|
4
|
+
if ENV["RUBY_DNN_DOWNLOADS_PATH"]
|
5
|
+
DOWNLOADS_PATH = ENV["RUBY_DNN_DOWNLOADS_PATH"]
|
6
|
+
else
|
7
|
+
DOWNLOADS_PATH = __dir__
|
8
|
+
end
|
4
9
|
|
5
10
|
class DNN_DownloadError < DNN_Error; end
|
6
11
|
|
7
12
|
class Downloader
|
8
13
|
def self.download(url, dir_path = nil)
|
9
14
|
unless dir_path
|
10
|
-
Dir.mkdir("#{
|
11
|
-
dir_path = "#{
|
15
|
+
Dir.mkdir("#{DOWNLOADS_PATH}/downloads") unless Dir.exist?("#{DOWNLOADS_PATH}/downloads")
|
16
|
+
dir_path = "#{DOWNLOADS_PATH}/downloads"
|
12
17
|
end
|
13
18
|
Downloader.new(url).download(dir_path)
|
14
19
|
rescue => e
|
@@ -20,7 +20,7 @@ module DNN
|
|
20
20
|
URL_TEST_LABELS = URL_BASE + TEST_LABELS_FILE_NAME
|
21
21
|
|
22
22
|
def self.downloads
|
23
|
-
Dir.mkdir("#{
|
23
|
+
Dir.mkdir("#{DOWNLOADS_PATH}/downloads") unless Dir.exist?("#{DOWNLOADS_PATH}/downloads")
|
24
24
|
Dir.mkdir(mnist_dir) unless Dir.exist?(mnist_dir)
|
25
25
|
Downloader.download(URL_TRAIN_IMAGES, mnist_dir) unless File.exist?(get_file_path(TRAIN_IMAGES_FILE_NAME))
|
26
26
|
Downloader.download(URL_TRAIN_LABELS, mnist_dir) unless File.exist?(get_file_path(TRAIN_LABELS_FILE_NAME))
|
@@ -79,7 +79,7 @@ module DNN
|
|
79
79
|
end
|
80
80
|
|
81
81
|
private_class_method def self.mnist_dir
|
82
|
-
"#{
|
82
|
+
"#{DOWNLOADS_PATH}/downloads/fashion-mnist"
|
83
83
|
end
|
84
84
|
|
85
85
|
private_class_method def self.get_file_path(file_name)
|
data/lib/dnn/datasets/iris.rb
CHANGED
data/lib/dnn/datasets/mnist.rb
CHANGED
@@ -19,7 +19,7 @@ module DNN
|
|
19
19
|
URL_TEST_LABELS = URL_BASE + TEST_LABELS_FILE_NAME
|
20
20
|
|
21
21
|
def self.downloads
|
22
|
-
Dir.mkdir("#{
|
22
|
+
Dir.mkdir("#{DOWNLOADS_PATH}/downloads") unless Dir.exist?("#{DOWNLOADS_PATH}/downloads")
|
23
23
|
Dir.mkdir(mnist_dir) unless Dir.exist?(mnist_dir)
|
24
24
|
Downloader.download(URL_TRAIN_IMAGES, mnist_dir) unless File.exist?(get_file_path(TRAIN_IMAGES_FILE_NAME))
|
25
25
|
Downloader.download(URL_TRAIN_LABELS, mnist_dir) unless File.exist?(get_file_path(TRAIN_LABELS_FILE_NAME))
|
@@ -78,7 +78,7 @@ module DNN
|
|
78
78
|
end
|
79
79
|
|
80
80
|
private_class_method def self.mnist_dir
|
81
|
-
"#{
|
81
|
+
"#{DOWNLOADS_PATH}/downloads/mnist"
|
82
82
|
end
|
83
83
|
|
84
84
|
private_class_method def self.get_file_path(file_name)
|
data/lib/dnn/version.rb
CHANGED
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: 0.13.
|
4
|
+
version: 0.13.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unagiootoro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|