summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2016-01-27 17:30:29 +0100
committerPatrick Simianer <p@simianer.de>2016-01-27 17:30:29 +0100
commita45efc2a559cd62b25523e6d37a4c1a35c66884f (patch)
tree4e4b31053f1737b7e870a5b829023fd06afe2801 /util
parent0d6cba6fae908b023cd228449bd2e721735cb016 (diff)
util/convlr.rb: generate directly applyable learning rates from update and gradient histories learned with AdaDelta
Diffstat (limited to 'util')
-rwxr-xr-xutil/convlr.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/util/convlr.rb b/util/convlr.rb
new file mode 100755
index 0000000..864f397
--- /dev/null
+++ b/util/convlr.rb
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+
+require 'zipf'
+
+updates = SparseVector.new
+ReadFile.readlines_strip(ARGV[0]).each { |line|
+ k,v = line.split
+ updates[k] = v.to_f
+}
+grads = SparseVector.new
+ReadFile.readlines_strip(ARGV[1]).each { |line|
+ k,v = line.split
+ grads[k] = v.to_f
+}
+
+smooth = 0.000001
+
+ks = updates.keys + grads.keys
+
+rates = SparseVector.new
+ks.each { |k|
+ rates[k] = -1*(Math.sqrt(updates[k]+smooth)/Math.sqrt(grads[k]+smooth))
+}
+
+rates.each { |k,v|
+ puts "#{k} #{v}"
+}
+