12.5 record time study

1.np.repeat https://blog.csdn.net/u010496337/article/details/50572866/

import numpy as np
a=np.array(([1,2],[3,4]))
print(np.repeat(a,2))

#结果:
[1 1 2 2 3 3 4 4]

When the time axis = None, flattens as a row vector.

If the specified axis:

Print (np.repeat (A, 2 , Axis = 0 )) 

# Results 
[[ . 1  2 ] 
 [ . 1  2 ] 
 [ . 3  . 4 ] 
 [ . 3  . 4 ]]

2.DE work.

If the two cell types is specified, then the samples from the two kinds of cell types N_SAMPLES, of course, better, to obtain the model after VAE px_scales (corrected) expressed as a percentage, then it is calculated using Bayes factor beta , it is determined by the size of the two matrices, and averaging, log (res / 1-res).

If it is 1 vs all, then in turn request, the type of the sample cell 1 of the current cell, and the other as another cell, and Bayesian factor gene.

3. For np.random.choice function

numpy Import AS NP 
Print (np.random.choice ([ . 1 , 2 , . 3 , . 4 ], 10 )) 

# result 
[ . 3  . 4  2  . 1  . 4  . 3  . 1  . 4  . 1  . 3 ] 
If the number of requests is greater than the length of the array, it is the original such automatic sampling can be repeated ah.

4 to be divided into two batches, one being a localized different batches of the same data, the other is different batches of the plurality of data sets, a bit more complex than expected.

5.logger.debug 

This message appears when debugging.

6.NearestNeighbors https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.NearestNeighbors.html

# Or check a good document, and then will be able to see the realization of the source code.

7. The calculation of entropy but really difficult to understand:

        score += np.mean(
            [
                entropy(
                    batches[#Returns a tuple of arrays (row,col) containing the indices
                        kmatrix[indices].nonzero()[1][#找到权重不为0的
                            kmatrix[indices].nonzero()[0] == i
                        ]
                    ]
                )
                for i in range(n_samples_per_pool)#100
            ]
        )

Finally came to understand, cited an example:

import numpy as np
km=np.array([[0,0,1],[1,0,0],[0,1,0]])
indices=[0,2]
print(km[indices].nonzero()[1][km[indices].nonzero()[0]==0])

#输出
[2]
>>> km[indices].nonzero()
(array([0, 1], dtype=int64), array([2, 1], dtype=int64))
>>> km[indices].nonzero()[0]==0
array([ True, False])
>>> km[indices].nonzero()[1]
array([2, 1], dtype=int64)

8. The use of cross-entropy function:

 

 When fre tends to 0 or 1, that is, almost all belong to the same batch of time, entropy tends to zero.

9. to learn about cross-entropy.

https://blog.csdn.net/tsyccnh/article/details/79163834 (to be watching)

10.tf.onehot, and the original categories, the category of data conversion according to onehot type.

https://blog.csdn.net/nini_coded/article/details/79250600

import tensorflow as tf  
      
classes = 3
labels = tf.constant([0,1,2]) # 输入的元素值最小为0,最大为2
output = tf.one_hot(labels,classes)

sess = tf.Session()
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    output = sess.run(output)
    print("output of one-hot is : ",output)

# ('output of one-hot is : ',
# array([[ 1.,  0.,  0.],
#       [ 0.,  1.,  0.],
#       [ 0.,  0.,  1.]], dtype=float32))

And manually try a bit:

import tensorflow as tf
a=tf.one_hot([0,0,0,1,1,1],2)
with tf.Session() as sess:
    print(sess.run(a))

#输出
[[1. 0.]
 [1. 0.]
 [1. 0.]
 [0. 1.]
 [0. 1.]
 [0. 1.]]

11.tf.random_normal https://blog.csdn.net/dcrmg/article/details/79028043

b= tf.random_normal([10])
with tf.Session() as sess:
    print(sess.run(b))

#输出
[-0.7680359   0.9331585   0.14169899  0.75573707 -1.3931639  -0.7400114
  0.58605003  1.8533127  -0.17746244 -1.0043402 ]

Is used to specify the value of the distribution is too removed from the subject to the specified number of values. No parameter is specified, then, it is the standard normal distribution.

12. The network layer function is not activated? dense (h, self.n_input, activation = None)

https://cloud.tencent.com/developer/article/1061802 (to be watching)

Corresponding to f (x) = x.

13.tf.nn.softplus  https://blog.csdn.net/ai_lx/article/details/88953587

import tensorflow as tf

a = tf.constant([-1.0, 12.0])
with tf.Session() as sess:
    b = tf.nn.softplus(a)
    print(sess.run(b))

#输出
[ 0.31326166 12.000006  ]

Is soft plus. # Is not softmax, not normalized.

The formula is: log (exp (features) + 1), a is the input features.

14. The search ZINB implementation code, failed, failed to find a similar,

Search case_zero case_non_zero, find a fitting explanation ZINB distribution, https://jdblischak.github.io/singlecell-qtl/zinb.html , looks too complicated.

That is, the likelihood computing ZINB time is so counted:

 

 Then the general likelihood value is calculated? How to calculate the likelihood.

In general, given the parameters θ and the distribution of the original data and obedience, likelihood values ​​can be calculated, the current value of the parameter likelihood. But now I feel abstract, there is no example.

 

 

 

 

Guess you like

Origin www.cnblogs.com/BlueBlueSea/p/11992190.html