-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
In Matrix.lua, the routine mat.newfromlabel has a loop using grid.cols.
However, grid.cols is set to 1. And the the variable j is never used:
--New matrix from a given label, for classification
function mat.newfromlabel(rows,label_index)
local grid ={}
grid.rows = rows
grid.cols = 1
grid.matrix = {}
local j = 1
for i=1,rows do
grid.matrix[i] = {}
for k=1,grid.cols do
if i == label_index then
grid.matrix[i][k] = 1
else
grid.matrix[i][k] = 0
end
end
end
return grid
end
It looks like this code is a rewrite of the prior function, ** mat.newrdn()**. Perhaps editing out the unused code would make it more clear what the routine is doing:
--New matrix from a given label, for classification
function mat.newfromlabel(rows,label_index)
-- create the grid object
local grid ={}
-- set the attributes
grid.rows = rows
grid.cols = 1
-- create a matrix with a single column
local matrix = {}
for i=1,rows do
matrix[i] = {0}
end
-- set the column with at label_index to 1
matrix[label_index][1] = 1
-- assign the matrix to the grid
grid.matrix = matrix
return grid
end
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels