ruby-dnn 0.13.3 → 0.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd3d1988c50c875fa619ab6c525fd604c8f264731c965f31725dd80ca8b17d72
4
- data.tar.gz: 7149096f7222c5a4d42bfa69121a99c5df97ca054ae90de7f7c7fc9a294e7c53
3
+ metadata.gz: cfe06541a0afe5fd3465839f02865efe7105c7635003840f60fd46e2976b0c26
4
+ data.tar.gz: d0f2150f86fe1ee423231c410af8809cecf9d412ecefebb0a3bee1ea14abeee7
5
5
  SHA512:
6
- metadata.gz: 4ba83b8274994a9b90be17231791d1935de015dc2963ec4cc47f98f12782c8f4ac342aa220492c4e43d4a5d7780dae2011ba1b6fc967a23538b22318890bbb5a
7
- data.tar.gz: 5374ea0e296ba510ce13d602daa4ffbc31757800ba9a83003f4795f195e4917511935d1bd7279ba8ce7204e78e73c7d2f918789452f329177fbd80eee981df3c
6
+ metadata.gz: 65ad242e2647f2035409432b6568a72d73b95a10b096d863938f9e0cef3bc07aac9a770a9d900d021af2afc3f912a9a3ed4725ba6488411c758b5f5a717a8964
7
+ data.tar.gz: d4102ded5ade667087736ecea6f897f1136b138682c93a53869e68b3fa70683a3bc8570e3ef3eb840c0a5f13ceb38a7f41b6c9a6f6b4d9bee9543b52ead2a95a
@@ -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
- loader = Loaders::MarshalLoader.new(self.new)
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
@@ -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?(__dir__ + "/downloads/" + DIR_CIFAR10)
14
+ return if Dir.exist?(DOWNLOADS_PATH + "/downloads/" + DIR_CIFAR10)
15
15
  Downloader.download(URL_CIFAR10)
16
- cifar10_binary_file_name = __dir__ + "/downloads/" + URL_CIFAR10.match(%r`.+/(.+)`)[1]
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, __dir__ + "/downloads")
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 = __dir__ + "/downloads/#{DIR_CIFAR10}/data_batch_#{i}.bin"
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 = __dir__ + "/downloads/#{DIR_CIFAR10}/test_batch.bin"
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?(__dir__ + "/downloads/" + DIR_CIFAR100)
14
+ return if Dir.exist?(DOWNLOADS_PATH + "/downloads/" + DIR_CIFAR100)
15
15
  Downloader.download(URL_CIFAR100)
16
- cifar100_binary_file_name = __dir__ + "/downloads/" + URL_CIFAR100.match(%r`.+/(.+)`)[1]
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, __dir__ + "/downloads")
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 = __dir__ + "/downloads/#{DIR_CIFAR100}/train.bin"
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 = __dir__ + "/downloads/#{DIR_CIFAR100}/test.bin"
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("#{__dir__}/downloads") unless Dir.exist?("#{__dir__}/downloads")
11
- dir_path = "#{__dir__}/downloads"
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("#{__dir__}/downloads") unless Dir.exist?("#{__dir__}/downloads")
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
- "#{__dir__}/downloads/fashion-mnist"
82
+ "#{DOWNLOADS_PATH}/downloads/fashion-mnist"
83
83
  end
84
84
 
85
85
  private_class_method def self.get_file_path(file_name)
@@ -52,7 +52,7 @@ module DNN
52
52
  end
53
53
 
54
54
  private_class_method def self.url_to_file_name(url)
55
- __dir__ + "/downloads/" + url.match(%r`.+/(.+)$`)[1]
55
+ DOWNLOADS_PATH + "/downloads/" + url.match(%r`.+/(.+)$`)[1]
56
56
  end
57
57
  end
58
58
  end
@@ -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("#{__dir__}/downloads") unless Dir.exist?("#{__dir__}/downloads")
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
- "#{__dir__}/downloads/mnist"
81
+ "#{DOWNLOADS_PATH}/downloads/mnist"
82
82
  end
83
83
 
84
84
  private_class_method def self.get_file_path(file_name)
@@ -1,3 +1,3 @@
1
1
  module DNN
2
- VERSION = "0.13.3"
2
+ VERSION = "0.13.4"
3
3
  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: 0.13.3
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-10 00:00:00.000000000 Z
11
+ date: 2019-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray