Created
July 27, 2011 14:08
-
-
Save anonymous/1109434 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'narray' | |
class LoadMatrix | |
def load_numbers(filename) | |
matrix = [] | |
File.open(filename) do |file| | |
file.each_line do |line| | |
ary = [] | |
line.split(" ").each{ |n| ary << n.to_f } | |
matrix << ary | |
end | |
end | |
matrix = NArray.to_na(matrix) | |
matrix = matrix.transpose | |
end | |
def load_dna(filename): | |
matrix=[] | |
File.open(filename) do |file| | |
file.each_line do |line| | |
line.split("\n").each{|n| matrix << n } | |
end | |
end | |
matrix | |
end | |
def load_cubes(filename): | |
matrix=[] | |
File.open(filename) do |file| | |
file.each_line do |line| | |
line.split("\n").each{|n| matrix << n } | |
end | |
end | |
matrix | |
end | |
def load_labels(self, filename): | |
matrix = [] | |
File.open(filename) do |file| | |
file.each_line do |line| | |
ary = [] | |
line.split(" ").each{ |n| ary << n.to_f } | |
matrix << ary | |
end | |
end | |
matrix = NArray.to_na(matrix)t | |
matrix = matrix.reshape(1, matrix.total) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment