【Golang】Goroutine截获输出和错误
Goroutine获取输出
通过chan获取到输出。
参考这个程序代码:
https://github.com/Chengru-Song/algo_practice/blob/master/conc/conc.go
func ConcPattern() {
ch1 := make(chan int)
ch2 := make(chan int)
// var wg sync.WaitGroup
// wg.Add(1)
// wg.Wait()
go func(ch chan int) {
time.Sleep(time.Second * 1)
ch <- 1
}(ch1)
go func(ch chan int) {
// defer wg.D...
【Golang】Golang Map并发编程
Golang Map并发读写
直接并发读写
如果直接对map进行并发读写,那么会造成Panic或者error,如下所示:
package main
func main() {
m := make(map[int]int)
go func() {
for {
read := m[0] // sync read
}
}()
go func() {
for {
m[0] = 1 // sync write
}
}()
}
上面程序有问题
传统加锁读写
package main
func main() {
m := make(map[int]int)
mc := sync.Mutex
...
【AI】Item2Vec详解
item2vec
Usage: item2vec learns item similarity.
Motivation
Item2item relations are important because different than the traditional user2item relations, it shows a more explicit user intent of purchasing. Therefore it has a higher click-through rate.
Solution
Skip Gram
Skip-gram is used to predict context words given a target word.
For...
【AI】WMAPE详解
WMAPE
Advantage: The advantage of this metric over MAPE is that this overcomes the ‘infinite error’ issue.
Key word: Evaluation
Usage: A measure of prediction accuracy of a forecasting method.
WMAPE: weighted mean absolute percentage error’
A measure of prediction accuracy of a forecasting method.
\[\begin{equation}
WMAPE = \frac{\sum^n_{t=1...
【AI】LSTM+CNN详解
LSTM + CNN
Introduction
Solution
Why sigmoid?
Sigmoid function is 0 - 1 layout, it could be used to remember or forget something.
Why tanh
We want to avoid vanishing gradient problem. The second derivative of tanh is mo
【Golang】Golang语言基础(面经)
Basic Knowledge
声明
短变量声明只能在函数内部使用
package main
// myvar := 1 // false
var myvar = 1 // right
func main() {
}
不能使用nil初始化未指定类型的变量
var x = nil // false
var x interface{} = nil // right
_ = x
字符串没有nil
var x string
if x == nil { // err
}
if x == "" {
x = "default"
}
Slice & Array
首先Slice和Array是有区别的,Slice是指针,而Array已经预...
【AI】One-hot Vector实例
One-Hot Encoding
Key word: Encoding
Label Encoding
| Food Name | Categorical | Calories |
| — | — | — |
| Apple | 1 | 95 |
| Chicken | 2 | 231 |
| Broccoli | 3 | 50 |
One-hot encoding
Apple
Chicken
Broccoli
Calories
1
0
0
95
0
1
0
...
【AI】ESMM CVR预测详解
ESMM
Advantage: Combine two nn together with by a dot product finally.
Key word: DNN
Usage: Predict CVR and CTR
Predicting post-click conversion rate is the problem they try to solve.
Why the Problem Is Difficult
Current method has two problems, one is illustrated as the following.
Sample selection bias problem means that the traini...
共计 124 篇文章,16 页。