forked from emer/leabra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreader.go
More file actions
56 lines (45 loc) · 1.18 KB
/
reader.go
File metadata and controls
56 lines (45 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
//"strconv"
)
// Users struct which contains
// an array of users
type Model struct {
Models []RecvLayer `json:"Model"`
}
// User struct which contains a name
// a type and a list of social links
type RecvLayer struct {
GScale float32 `json:"gscale"`
SendLayer []RecvPrjn `json:"SendLayer"`
}
// Social struct which contains a
// list of links
type RecvPrjn struct {
N int `json:"SendNeurons"`
Si []int `json:"Synapse Index"`
Wt []float32 `json:"Weights"`
}
func main() {
// Open our jsonFile
jsonFile, err := os.Open("SUMMER_Base_000_00032.wts")
// if we os.Open returns an error then handle it
if err != nil {
fmt.Println(err)
}
fmt.Println("Successfully Opened weight files")
// defer the closing of our jsonFile so that we can parse it later on
defer jsonFile.Close()
// read our opened xmlFile as a byte array.
byteValue, _ := ioutil.ReadAll(jsonFile)
// we iterate through every user within our users array and
// print out the user Type, their name, and their facebook url
// as just an example
var result map[string]interface{}
json.Unmarshal([]byte(byteValue), &result)
fmt.Println(len(result))
}