ruby-cntk 0.1.0.pre1 → 0.1.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,109 @@
1
+ require "numo/narray"
2
+
3
+ module CNTK
4
+
5
+ class Variable
6
+ DataType = { DataType_Float => Numo::SFloat, DataType_Double => Numo::DFloat, DataType_Unknown => nil }
7
+
8
+ def is_scalar
9
+ shape().rank == 0
10
+ end
11
+
12
+ def dynamic_axes
13
+ __dynamic_axes__.reverse
14
+ end
15
+
16
+ def reshape(shape)
17
+ Ops.reshape(self, shape)
18
+ end
19
+
20
+ # follow Numo::Narray
21
+ def dot(other)
22
+ if shape.rank == 1 and other.shape.rank == 1
23
+ ret = Ops.times( Ops.reshape(self, [1,shape.total_size]),
24
+ Ops.reshape(other, [other.shape.total_size, 1]) )
25
+ Ops.reshape(ret, [1])
26
+ else
27
+ Ops.times(self, other)
28
+ end
29
+ end
30
+
31
+ def *(other)
32
+ Ops.element_times(self, other)
33
+ end
34
+
35
+ def /(other)
36
+ Ops.element_divide(self, other)
37
+ end
38
+
39
+ def +(other)
40
+ Ops.plus(self, other)
41
+ end
42
+
43
+ def -(other)
44
+ Ops.minus(self, other)
45
+ end
46
+
47
+ def coerce(other)
48
+ if other.is_a?(Numeric)
49
+ [CNTK::Ops.constant(other), self]
50
+ else
51
+ [other, self]
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ module VariableExtend
58
+ def create_from(val, shape, dtype, device, name)
59
+ case val
60
+ when NDArrayView, Value, Variable, Numo::NArray
61
+ if shape
62
+ raise "can't accept #{val.class} and shape at the same time"
63
+ end
64
+ case val
65
+ when Variable
66
+ new(val)
67
+ when NDArrayView
68
+ new(val, name)
69
+ when Value
70
+ new(val.data, name)
71
+ else
72
+ new(NDArrayView.create(val), name)
73
+ end
74
+ when Numeric, Dictionary
75
+ if shape
76
+ new(shape, dtype, val, device, name)
77
+ else
78
+ new([], dtype, val, device, name)
79
+ end
80
+ else
81
+ raise ArgumentError, "NDArrayView, Value, Variable, Numo::NArray, Initializer, or Numeric expected"
82
+ end
83
+ end
84
+ end
85
+
86
+ class Constant # < Variable
87
+ extend VariableExtend
88
+ def self.create(val, shape: nil, dtype: DataType_Float, device: DeviceDescriptor::use_default_device(), name: "")
89
+ create_from(val, shape, dtype, device, name)
90
+ end
91
+
92
+ def *(other)
93
+ if is_scalar
94
+ CNTK.__times__(other, self)
95
+ else
96
+ CNTK.__times__(self, other)
97
+ end
98
+ end
99
+
100
+ end
101
+
102
+ class Parameter # < Variable
103
+ extend VariableExtend
104
+ def self.create(shape: nil, init: 0, dtype: DataType_Float, device: DeviceDescriptor::use_default_device(), name: "")
105
+ create_from(init, shape, dtype, device, name)
106
+ end
107
+ end
108
+
109
+ end
data/lib/cntk.rb CHANGED
@@ -1,5 +1,20 @@
1
1
  require "cntk/CNTK"
2
+ require "cntk/axis"
3
+ require "cntk/dictionary"
2
4
  require "cntk/function"
5
+ require "cntk/initializer"
6
+ require "cntk/inspect"
7
+ require "cntk/io"
8
+ require "cntk/layers"
9
+ require "cntk/learner"
10
+ require "cntk/ndmask"
3
11
  require "cntk/ndshape"
4
12
  require "cntk/ndarrayview"
13
+ require "cntk/ops"
14
+ require "cntk/trainer"
5
15
  require "cntk/value"
16
+ require "cntk/variable"
17
+
18
+ module CNTK
19
+ remove_method( *private_instance_methods(false) )
20
+ end
File without changes
@@ -0,0 +1,65 @@
1
+ # Microsoft Computational Network Toolkit (CNTK)
2
+
3
+ Copyright (c) Microsoft Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
11
+ ## THIRD PARTY NOTICES
12
+
13
+ This project is based on or incorporates material from the projects listed below (Third Party IP). The original copyright notice and the license under which Microsoft received such Third Party IP, are set forth below. Such licenses and notices are provided for informational purposes only. Where permitted, Microsoft licenses the Third Party IP to you under the licensing terms for the Microsoft product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
14
+
15
+ ### a. INTEL (R) MATH KERNEL LIBRARY (INTEL (R) MKL)
16
+
17
+ CNTK distribution contains Redistributable components of Intel (r) Math Kernel Library (Intel (r) MKL)
18
+
19
+ ### b. BOOST C++ LIBRARIES
20
+
21
+ Copyright Beman Dawes, David Abrahams, 1998-2005.
22
+ Copyright Rene Rivera 2004-2007.
23
+
24
+ Provided for Informational Purposes Only
25
+
26
+ Boost Software License - Version 1.0 - August 17th, 2003
27
+
28
+ Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
29
+
30
+ The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.
31
+
32
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
+
34
+ ### c. ATIS DATASETS
35
+
36
+ CNTK distribution contains a subset of ATIS Datasets:
37
+
38
+ Hemphill, Charles, et al. ATIS0 Complete LDC93S4A. Web Download. Philadelphia: Linguistic Data Consortium, 1993.
39
+
40
+ Garofolo, John, et al. ATIS2 LDC93S5. Web Download. Philadelphia: Linguistic Data Consortium, 1993.
41
+
42
+ Dahl, Deborah, et al. ATIS3 Test Data LDC95S26. Web Download. Philadelphia: Linguistic Data Consortium, 1995.
43
+
44
+ Dahl, Deborah, et al. ATIS3 Training Data LDC94S19. Web Download. Philadelphia: Linguistic Data Consortium, 1994.
45
+
46
+ ### d. TIMIT ACOUSTIC-PHONETIC CONTINUOUS SPEECH CORPUS
47
+
48
+ CNTK distribution contains a subset of TIMIT Acoustic-Phonetic Continuous Speech Corpus:
49
+
50
+ Garofolo, John, et al. TIMIT Acoustic-Phonetic Continuous Speech Corpus LDC93S1. Web Download. Philadelphia: Linguistic Data Consortium, 1993.
51
+
52
+ ### e. THE PENN TREEBANK PROJECT
53
+
54
+ CNTK distribution contains a subset of the data of The Penn Treebank Project:
55
+
56
+ Marcus, Mitchell, Beatrice Santorini, and Mary Ann Marcinkiewicz. Treebank-2 LDC95T7. Web Download. Philadelphia: Linguistic Data Consortium, 1995.
57
+
58
+ ### f. THE CMU AUDIO DATABASES
59
+
60
+ CNTK distribution contains a subset of the CMU Audio Databases
61
+ Copyright (c) 1991-2005 Carnegie Mellon University. All rights reserved.
62
+
63
+ ### g. THE MNIST DATABASE OF HANDWRITTEN DIGITS
64
+
65
+ CNTK distribution contains a subset of the MNIST Database of Handwritten Digits
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-cntk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre1
4
+ version: 0.1.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Tamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-12 00:00:00.000000000 Z
11
+ date: 2017-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.5
27
- description: Ruby bindings for Microsoft Cognitive Toolkit (CNTK), an open source
27
+ description: Ruby bindings for Microsoft Cognitive Toolkit (CNTK), an open source
28
28
  deep-learning toolkit
29
29
  email: ''
30
30
  executables: []
@@ -32,14 +32,26 @@ extensions:
32
32
  - ext/cntk/extconf.rb
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - LICENSE
36
35
  - ext/cntk/cntk_wrap.cxx
37
36
  - ext/cntk/extconf.rb
38
37
  - lib/cntk.rb
38
+ - lib/cntk/axis.rb
39
+ - lib/cntk/dictionary.rb
39
40
  - lib/cntk/function.rb
41
+ - lib/cntk/initializer.rb
42
+ - lib/cntk/inspect.rb
43
+ - lib/cntk/io.rb
44
+ - lib/cntk/layers.rb
45
+ - lib/cntk/learner.rb
40
46
  - lib/cntk/ndarrayview.rb
47
+ - lib/cntk/ndmask.rb
41
48
  - lib/cntk/ndshape.rb
49
+ - lib/cntk/ops.rb
50
+ - lib/cntk/trainer.rb
42
51
  - lib/cntk/value.rb
52
+ - lib/cntk/variable.rb
53
+ - licenses/LICENSE
54
+ - licenses/LICENSE_cntk.md
43
55
  homepage: https://github.com/tamuratak/ruby-cntk
44
56
  licenses:
45
57
  - MIT