mirror of
https://github.com/sjwhitworth/golearn.git
synced 2025-04-25 13:48:49 +08:00
Fix various other little errors
This commit is contained in:
parent
ff52c013eb
commit
2428dfa7de
@ -164,16 +164,19 @@ func DeserializeInstancesFromTarReader(tr *FunctionalTarReader, prefix string) (
|
||||
|
||||
// Finally, read the values out of the data section
|
||||
for i := 0; i < rowCount; i++ {
|
||||
for _, s := range specs {
|
||||
for j, s := range specs {
|
||||
r := ret.Get(s, i)
|
||||
n, err := reader.Read(r)
|
||||
if n != len(r) {
|
||||
return nil, fmt.Errorf("Expected %d bytes (read %d) on row %d", len(r), n, i)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Read error: %s", err)
|
||||
return nil, WrapError(fmt.Errorf("Expected %d bytes (read %d) on row %d", len(r), n, i))
|
||||
}
|
||||
ret.Set(s, i, r)
|
||||
if err != nil {
|
||||
if i == rowCount-1 && j == len(specs)-1 && err == io.EOF {
|
||||
break
|
||||
}
|
||||
return nil, WrapError(fmt.Errorf("Read error in data section (at row %d from %d, attr %d from %d): %s", i, rowCount, j, len(specs), err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,6 +303,9 @@ func SerializeInstancesToTarWriter(inst FixedDataGrid, tw *tar.Writer, prefix st
|
||||
}
|
||||
|
||||
allSpecs := ResolveAttributes(inst, allAttrs)
|
||||
if len(allSpecs) != len(allAttrs) {
|
||||
return WrapError(fmt.Errorf("Error resolving all Attributes: resolved %d, expected %d", len(allSpecs), len(allAttrs)))
|
||||
}
|
||||
|
||||
// First, estimate the amount of data we'll need...
|
||||
dataLength := int64(0)
|
||||
|
@ -176,7 +176,7 @@ func (m *OneVsAllModel) LoadWithPrefix(reader *base.ClassifierDeserializer, pref
|
||||
attrMap := make(map[base.Attribute]base.Attribute)
|
||||
|
||||
for j := 0; j < int(numAttrsInMapU64); j++ {
|
||||
mapTupleKey := reader.Prefix(mapPrefix, fmt.Sprintf("%d"))
|
||||
mapTupleKey := reader.Prefix(mapPrefix, fmt.Sprintf("%d", j))
|
||||
mapKeyKeyKey := reader.Prefix(mapTupleKey, "KEY")
|
||||
mapKeyValKey := reader.Prefix(mapTupleKey, "VAL")
|
||||
|
||||
@ -289,7 +289,7 @@ func (m *OneVsAllModel) SaveWithPrefix(writer *base.ClassifierSerializer, prefix
|
||||
}
|
||||
j := 0
|
||||
for key := range f.attrs {
|
||||
mapTupleKey := writer.Prefix(mapPrefix, fmt.Sprintf("%d"))
|
||||
mapTupleKey := writer.Prefix(mapPrefix, fmt.Sprintf("%d", j))
|
||||
mapKeyKeyKey := writer.Prefix(mapTupleKey, "KEY")
|
||||
mapKeyValKey := writer.Prefix(mapTupleKey, "VAL")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user