summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2016-01-29 18:17:46 +0100
committerPatrick Simianer <p@simianer.de>2016-01-29 18:17:46 +0100
commit7d35b712d33cca0be3af122ecffbbfa7cbc123b2 (patch)
tree5d90cb23f0a5514e706bf31ae5b232d011516b3e /util
parent3a45a4076187de8cac3be1f562fb583ee6724a50 (diff)
cleanup
Diffstat (limited to 'util')
-rwxr-xr-xutil/adadelta_rate_conv.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/util/adadelta_rate_conv.rb b/util/adadelta_rate_conv.rb
new file mode 100755
index 0000000..c845847
--- /dev/null
+++ b/util/adadelta_rate_conv.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] = Math.sqrt(updates[k]+smooth)/Math.sqrt(grads[k]+smooth)
+}
+
+rates.each { |k,v|
+ puts "#{k} #{v}"
+}
+