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
| def makeModel1(): | |
| inputs = tf.placeholder("float", [None,10]) | |
| network1 = tf.Variable(tf.truncated_normal([10,20],stddev=0.01)) | |
| biases1 = tf.Variable(tf.truncated_normal([20],stddev=0.01)) | |
| layer1=tf.nn.relu(tf.matmul(inputs, network1)+biases1) | |
| network2 = tf.Variable(tf.truncated_normal([10,20],stddev=0.01)) | |
| biases2 = tf.Variable(tf.truncated_normal([20],stddev=0.01)) | |
| layer2=tf.nn.relu(tf.matmul(layer1, network2)+biases2) | |
| return layer2 |
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
| def makeModel1(): | |
| inputs = tf.placeholder("float", [None,10]) | |
| network1 = tf.Variable(tf.truncated_normal([10,20],stddev=0.01)) | |
| biases1 = tf.Variable(tf.truncated_normal([20],stddev=0.01)) | |
| layer1=tf.matmul(inputs, network1)+biases1 | |
| network2 = tf.Variable(tf.truncated_normal([10,20],stddev=0.01)) | |
| biases2 = tf.Variable(tf.truncated_normal([20],stddev=0.01)) | |
| layer2=tf.matmul(layer1, network2)+biases2 | |
| return layer2 |
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
| Wf = tf.Variable(tf.zeros([3, 3])) | |
| Wf = tf.Variable(tf.random_normal([3, 3])) | |
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
| inputs = [ | |
| [1., 0., 0.], | |
| [0., 1., 0.], | |
| [0., 0., 1.] | |
| ] | |
| winning_hands = [ | |
| [0., 1., 0.], | |
| [0., 0., 1.], | |
| [1., 0., 0.] |
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
| // string to int | |
| i, err := strconv.Atoi("255") | |
| i32, err := strconv.ParseInt("255", 10, 32) | |
| i64, err := strconv.ParseInt("255", 10, 64) | |
| ib16, err := strconv.ParseInt("ff", 16, 16) | |
| ib0, err := strconv.ParseInt("0xff", 0, 16) | |
| //int to string | |
| iStr := strconv.Itoa(255) | |
| i64str := strconv.FormatInt(255, 10) |
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
| func (self *ColumnType) ConvertToBytes(val interface{}) ([]byte, error) { | |
| var b []byte | |
| byteNum, err := self.GetBytes() | |
| if err != nil { | |
| return nil, err | |
| } | |
| if self.Type == "int64" { | |
| v, ok := val.(int64) | |
| if ok == false { | |
| return nil, errors.New("Missmatch type(int64) and val: " + self.Name) |
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
| func (self *Table) WriteRow(rowNum int64, row Row) (int64, error) { | |
| if rowNum == -1 { | |
| temp, err := self.searchLastOff() | |
| if err != nil { | |
| return -1, err | |
| } | |
| rowNum = temp | |
| } | |
| targetOff := self.convertRowNumToOffset(rowNum) | |
| var b []byte |
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
| func (self *Table) convertRowNumToOffset(rowNum int64) int64 { | |
| offset := int64(rowNum)*int64(self.columnBytes+1) + int64(binary.MaxVarintLen64) | |
| return offset | |
| } | |
| func (self *Table) convertOffsetToRowNum(offset int64) int64 { | |
| rowNum := int64((offset - int64(binary.MaxVarintLen64)) / (int64(self.columnBytes + 1))) | |
| return rowNum | |
| } |
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
| import "fmt" | |
| mapObj1 := map[string]int{"a": 1, "b": 2, "c": 3, "d": 4} | |
| for key, val := range mapObj1 { | |
| fmt.Printf("key:%s,val:%d\n", key, val) | |
| } | |
| v:=mapObj1["a"] | |
| fmt.Printf("key:%s,val:%d\n", "a", v) |
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
| import "os" | |
| func IsDirExist(directory string) (bool,error) { | |
| fInfo, err := os.Stat(directory) | |
| if err != nil { | |
| if os.IsExist(err) == false { | |
| return false, nil //Directory does not exist | |
| } else { | |
| return false, err //Something wrong | |
| } |
NewerOlder