Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't quite work #1

Open
mwlang opened this issue May 1, 2018 · 1 comment
Open

Doesn't quite work #1

mwlang opened this issue May 1, 2018 · 1 comment

Comments

@mwlang
Copy link

mwlang commented May 1, 2018

Hi, looks interesting. However, when I gave the example file a go, I get this:

>> ruby gru.rb
"a1 is ============"
Numo::DFloat#shape=[8,5]
[[-0.292547, -0.0390668, 0.178961, -0.169989, -0.0737522],
 [-0.231067, -0.394095, -0.195222, -0.354715, -0.11257],
 [0.118269, 0.0198059, 0.0240152, -0.310782, -0.144747],
 [0.053828, -0.0225093, 0.0259425, 0.417177, 0.24573],
 [-0.0788915, -0.0708086, 0.206781, 0.0311229, -0.074684],
 [-0.26492, -0.182851, 0.0272328, -0.0853396, 0.0567551],
 [-0.0655399, 0.0498864, 0.00537562, 0.00477271, -0.0207735],
 [-0.0671299, -0.069449, 0.0322151, 0.168066, 0.0472781]]
gru.rb:65:in `[]': 0...8 is out of range for size=5 (RangeError)
	from gru.rb:65:in `predict'
	from gru.rb:188:in `<main>'
11:58:26:Ruby-GRU >> ruby gru.rb
"a1 is ============"
Numo::DFloat#shape=[8,5]
[[-0.292547, -0.0390668, 0.178961, -0.169989, -0.0737522],
 [-0.231067, -0.394095, -0.195222, -0.354715, -0.11257],
 [0.118269, 0.0198059, 0.0240152, -0.310782, -0.144747],
 [0.053828, -0.0225093, 0.0259425, 0.417177, 0.24573],
 [-0.0788915, -0.0708086, 0.206781, 0.0311229, -0.074684],
 [-0.26492, -0.182851, 0.0272328, -0.0853396, 0.0567551],
 [-0.0655399, 0.0498864, 0.00537562, 0.00477271, -0.0207735],
 [-0.0671299, -0.069449, 0.0322151, 0.168066, 0.0472781]]
Numo::DFloat#shape=[8,1]
[[0],
 [0.00275633],
 [-0.00107287],
 [0.00119137],
 [-0.00412887],
 [0.00132137],
 [0.00150638],
 [0.000478691]]
-----------------------------
"a1 is ============"
Numo::DFloat#shape=[8,5]
[[-0.292547, -0.0390668, 0.178961, -0.169989, -0.0737522],
 [-0.231067, -0.394095, -0.195222, -0.354715, -0.11257],
 [0.118269, 0.0198059, 0.0240152, -0.310782, -0.144747],
 [0.053828, -0.0225093, 0.0259425, 0.417177, 0.24573],
 [-0.0788915, -0.0708086, 0.206781, 0.0311229, -0.074684],
 [-0.26492, -0.182851, 0.0272328, -0.0853396, 0.0567551],
 [-0.0655399, 0.0498864, 0.00537562, 0.00477271, -0.0207735],
 [-0.0671299, -0.069449, 0.0322151, 0.168066, 0.0472781]]
++++++++++++++++++++++++++
[[Numo::DFloat#shape=[21,5]
[[0, 0, 0, 0, 0],
 [-0.000567843, 0.000317709, -0.000319215, -0.000398534, 0.00125565],
 [-0.000567843, 0.000317709, -0.000319215, -0.000398534, 0.00125565],
 [0, 0, 0, 0, 0],
 [-0.00119052, 0.000378278, -0.00109157, -0.000733441, 0.00255223],
 [-0.00258889, 0.0016766, -0.00278893, -0.00152312, 0.00578596],
 [-0.00215646, 0.000908435, -0.00220595, -0.00156927, 0.00492153],
 [-0.00119052, 0.000378278, -0.00109157, -0.000733441, 0.00255223],
 [-0.00119052, 0.000378278, -0.00109157, -0.000733441, 0.00255223],
 [-0.00119052, 0.000378278, -0.00109157, -0.000733441, 0.00255223],
 [-0.00119052, 0.000378278, -0.00109157, -0.000733441, 0.00255223],
 [-0.00212692, 0.00164964, -0.00229604, -0.00131121, 0.00492763],
 [-0.00212692, 0.00164964, -0.00229604, -0.00131121, 0.00492763],
 [-0.00352529, 0.00294796, -0.0039934, -0.00210089, 0.00816135],
 [-0.00212692, 0.00164964, -0.00229604, -0.00131121, 0.00492763],
 [-0.00405932, 0.00310785, -0.00466295, -0.00280562, 0.00962166],
 [-0.00405932, 0.00310785, -0.00466295, -0.00280562, 0.00962166],
 [-0.00263115, 0.00233073, -0.00340069, -0.00173951, 0.00631717],
 [-0.00139837, 0.00129832, -0.00169737, -0.000789678, 0.00323373],
 [-0.00139837, 0.00129832, -0.00169737, -0.000789678, 0.00323373],
 ...,
  Numo::DFloat#shape=[10,5]
[[-5.5919e-06, -1.23727e-06, 1.19065e-06, 3.26516e-06, 1.55293e-07],
 [-2.69659e-06, -1.28504e-06, 1.2191e-06, 2.79103e-06, 2.64754e-07],
 [-1.8584e-06, -8.70963e-07, 8.41632e-07, 1.85605e-06, 1.75525e-07],
 [6.4969e-06, 2.52781e-06, -2.37683e-06, -5.91448e-06, -4.94884e-07],
 [-1.26784e-06, -1.07768e-06, 1.02513e-06, 2.12972e-06, 2.56903e-07],
 [2.45981e-06, 3.9992e-06, -3.41232e-06, -8.97293e-06, -1.10901e-06],
 [6.22211e-07, 6.61069e-07, -2.41907e-07, -2.42457e-06, -2.3038e-07],
 [2.43058e-06, 4.18335e-07, -4.68736e-07, -1.26211e-06, -6.98984e-08],
 [-3.89086e-06, -1.00846e-07, 4.87735e-07, 3.41851e-06, -2.07328e-08],
 [-1.34888e-06, 5.54077e-07, -5.48688e-07, 1.42211e-06, -8.81376e-08]],
  Numo::DFloat#shape=[10,5]
[[-1.72233e-05, -1.29931e-05, -1.05624e-05, 5.84491e-05, -5.80149e-06],
 [-1.21987e-05, -1.47105e-05, -1.23962e-05, 5.78117e-05, -7.45171e-06],
 [-7.71786e-06, -9.81021e-06, -8.57564e-06, 3.71305e-05, -5.18917e-06],
 [2.61386e-05, 2.55103e-05, 2.02095e-05, -0.000116082, 1.14645e-05],
 [-8.1393e-06, -1.29651e-05, -1.09046e-05, 4.86727e-05, -7.85318e-06],
 [5.92328e-05, 6.73025e-05, 5.9506e-05, -0.000347186, 3.77871e-05],
 [5.77251e-05, 5.71416e-05, 5.90559e-05, -0.000310832, 4.29394e-05],
 [2.65058e-05, 3.96853e-05, 3.63354e-05, -0.000187479, 4.38815e-05],
 [9.75184e-05, 0.000215935, 0.000185082, -0.000574499, 0.000193376],
 [3.87783e-05, 0.000105994, 9.58642e-05, -0.000228757, 9.3617e-05]],
  Numo::DFloat#shape=[10,5]
[[-0.000458056, -0.000598429, -0.000711855, -0.00116971, -0.000690919],
 [-0.000180995, -0.000236383, -0.000266294, -0.000449114, -0.000267509],
 [-0.000129157, -0.000171285, -0.000198403, -0.00032898, -0.000196663],
 [0.000455112, 0.000597406, 0.000685556, 0.00114225, 0.000681555],
 [-6.18102e-05, -9.00649e-05, -0.000102878, -0.000164444, -0.000104588],
 [-0.000915024, -0.00157388, -0.00260268, -0.0035928, -0.00219285],
 [-0.0013406, -0.00234972, -0.00368089, -0.00518152, -0.00321246],
 [0.000298067, 0.00034021, 0.000343422, 0.000512395, 0.000335641],
 [3.85298e-05, -0.000651838, -0.00160116, -0.00177307, -0.00133588],
 [0.000249109, 7.50605e-05, -0.000164267, 2.65139e-05, -0.000110004]],
  Numo::DFloat#shape=[5,1]
[[-0.00788467],
 [-0.00056698],
 [-0.000799404],
 [0.00536402],
 [0.00027779]]],
 [Numo::DFloat#shape=[5]
[-0.00941477, 0.00666472, -0.0105888, -0.00651294, 0.022116],
  Numo::DFloat#shape=[5]
[0.000140003, 2.59988e-05, -2.64779e-05, -6.83682e-05, -2.40387e-06],
  Numo::DFloat#shape=[5]
[0.000282522, 0.000230055, 0.000137169, -0.000780391, 0.000137628],
  Numo::DFloat#shape=[5]
[0.0292344, 0.0404843, 0.0516969, 0.0810661, 0.0486037],
  Numo::DFloat#shape=[1]
[0.499743]]]
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
"a1 is ============"
Numo::DFloat#shape=[1,5]
[[-0.0671299, -0.069449, 0.0322151, 0.168066, 0.0472781]]
gru.rb:68:in `[]': array index (1) is out of array size (1) (RangeError)
	from gru.rb:68:in `predict'
	from gru.rb:194:in `<main>'
@arjunmenon
Copy link
Owner

Hey
I will post a fix for that soon. This was something I was just experimenting, hence no code comments. As of now it simply calculates the weights and the bias, if you remove the last predict line, you can see that it runs. We just have to take the weights and put it into a softmax classifier.

If you are looking for a text-classifier, I have a ruby based NN solution for that, will upload that if you are interested.

I am working on certain other topics, as soon as I am done with them, which shouldn't be long, I will get back to ML. I had started projects for a Keras style framework and a Spacy type NLP solution for Ruby.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants