自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

/dev/null

Hope it helps!

  • 博客(33)
  • 收藏
  • 关注

原创 Batch Normalization和Layer Normalization的区别

网上有不少解释,包括下面这张图片光靠图片理解还是不够,而且特别容易理解反了。这里用一个实例进行讲解。一个非常简单的数据集,包含两个sample,3个features。第一个sample: X1=1.0,X2=1.0, X3=1.0第二个sample: X1=10.0,X2=10.0, X3=10.0data = tf.constant([1.0,1.0,1.0],[10.0,10.0,...

2020-04-27 21:41:20 797

原创 AttributeError: module 'tensorflow_core._api.v2.config' has no attribute 'list_physical_devices'

AttributeError: module ‘tensorflow_core._api.v2.config’ has no attribute ‘list_physical_devices’应该是接口更新了,改成以下接口就不会报错了。查看所有GPUtf.config.experimental.list_physical_devices('GPU')查看所有设备tf.config.ex...

2020-04-27 20:02:30 7832 2

原创 Ubuntu纯命令行安装并配置Teamviewer

卸载sudo apt-get purge teamviewer下载任意版本wget https://download.teamviewer.com/download/linux/version_14x/teamviewer_amd64.deb安装sudo apt install ./teamviewer_14.7.13736_amd64.deb可能出现以下报错,可以忽略...

2020-04-27 19:44:00 606

原创 在Jupyter中使用自定义conda环境

source activate myenvpython -m ipykernel install --user --name myenv --display-name "Python (myenv)"

2020-04-24 21:24:00 262

原创 TensorFLow: Gradient Clipping

The parameters clipnorm and clipvalue can be used with all optimizers to control gradient clipping。Keras的所有optimizer都可以使用clipnorm和clipvalue来防止梯度过大。from keras import optimizers# All parameter ...

2020-04-24 21:00:00 234

原创 Python partial 工具函数

partial函数可以提高代码利用率和简洁性:from functools import partialdef power(base, exponent, bias): return base * exponent + biassquared = partial(power, exponent=2, bias=100)In [7]: power(2,2,100) ...

2020-04-23 21:06:00 108

原创 lambda X, y: X

f = lambda X, y: Xf(2,2)2f([1,1]) <lambda>() missing 1 required positional argument: 'y'f([1,1],[2,2])[1,1]

2020-04-23 17:16:00 1247

原创 一个高效的TensorFlow数据集前处理代码

def csv_reader_dataset(filepaths, repeat=1, n_readers=5, n_read_threads=None, shuffle_buffer_size=10000, n_parse_threads=5, batch_size=32): datas...

2020-04-23 16:48:00 234

原创 一文讲解TensorFlow数据接口 tf.data.Dataset

导入数据X = pd.read_csv('./datasets/housing/housing.csv')X = X.sample(n=10)X.drop(columns = X.columns.difference(['longitude']), inplace=True)为了避免报错,先进行格式转换:X = np.asarray(X).astype(np.float32)...

2020-04-23 00:25:00 360

原创 TensorFlow regularization loss和model.losses

以如下模型为例,l2_reg = keras.regularizers.l2(0.05)model = keras.models.Sequential([ keras.layers.Dense(30, activation="elu", kernel_initializer="he_normal", kernel_regulari...

2020-04-22 20:13:00 1033

原创 手动实现TensorFlow的训练过程:示例

参考文献:Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systemsl2_reg = keras.regularizers.l2(0.05)model = keras.models.Seq...

2020-04-22 19:54:00 271

原创 一文总结Keras的loss函数和metrics函数

Loss函数定义:keras.losses.mean_squared_error(y_true, y_pred)用法很简单,就是计算均方误差平均值,例如loss_fn = keras.losses.mean_squared_errora1 = tf.constant([1,1,1,1])a2 = tf.constant([2,2,2,2])loss_fn(a1,a2)...

2020-04-22 19:17:00 3316

原创 TensorFlow Autodiff自动微分

with tf.GradientTape(persistent=True) as tape: z1 = f(w1, w2 + 2.) z2 = f(w1, w2 + 5.) z3 = f(w1, w2 + 7.) z = [z1,z3,z3][tape.gradient(z, [w1, w2]) for z in (z1, z2, z3)]输出结果...

2020-04-22 17:00:00 190

原创 Python/Numpy 矩阵运算符号@

A = np.matrix('3 1; 8 2')B = np.matrix('6 1; 7 9')A@Bmatrix([[25, 12], [62, 26]])

2020-04-22 16:30:00 1796

原创 tf.keras自定义损失函数

自定义损失函数In statistics, the Huber loss is a loss function used in robust regression, that is less sensitive to outliers in data than the squared error loss. A variant for classification is also so...

2020-04-21 18:01:00 1006

原创 Python 3.5以上版本合并两个Dict

x = {'a': 1, 'b': 2} y = {'b': 3, 'c': 4} z = {**x, **y}输出结果{'a': 1, 'b': 3, 'c': 4}注意:如果key相同,第二个dict的item会覆盖第一个dict的item。

2020-04-21 17:15:00 118

原创 TensorFlow的tf.where函数详解与例子

官方说明:If both x and y are None, then this operation returns the coordinates of true elements of condition. The coordinates are returned in a 2-D tensor where the first dimension (rows) represents...

2020-04-21 17:08:00 2277

原创 t[..., 1, tf.newaxis]

如果t是二维数组,t[...,1]等价于t[:,1];如果是三维数值,t[...,1]等价于t[:,:,1]。tf.newaxis和np.newaxis功能相同,都是增加维度。t=tf.constant([[1,2,3],[4,5,6]])<tf.Tensor: id=25, shape=(2, 3), dtype=int32, numpy=array([[1, 2, 3]...

2020-04-21 15:26:00 624

原创 Keras learning_phase()和learning_phase_scope()

tf.keras.backend.learning_phase()The learning phase flag is a bool tensor (0 = test, 1 = train) to be passed as input to any Keras function that uses a different behavior at train time and test ...

2020-04-20 22:24:00 1413

原创 Keras Sequential模型和add()

from keras.models import Sequentialfrom keras.layers import Dense, Activationmodel = Sequential([ Dense(32, input_shape=(784,)), Activation('relu'), Dense(10), Activation('soft...

2020-04-20 20:52:00 1938

原创 Keras克隆层

mdl_A = keras.models.load("mdl_A.hf")mdl_B_on_A = keras.models.Sequential(mdl_A.layers[:-1])mdl_B_on_A.add(keras.layers.Dense(1, activation = "sigmoid")需要注意的是,此时mdl_A和mdl_B共享神经网络的权重。解决的方法是使用c...

2020-04-20 20:33:00 216

原创 概率密度函数与最大似然估计的区别

概率密度函数(PDF)以高斯分布的概率密度函数(PDF)为例,\(f(x)=\frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x - \mu}{\sigma}\right)^2}\)期望值\(\mu\)和方差\(\sigma\)确定之后,\(f(x)\)是\(x\)的PDF函数。更一般地, \(f(x)\)可以认为是\(x...

2020-04-20 19:49:00 1920

原创 Keras搭建一个Wide & Deep 神经网络

Wide & Deep 神经网络2016年谷歌公司的Cheng等人发表的文章Wide & Deep Learning for Recommender Systems介绍了一种新的架构,Wide & Deep ANNs.通过将输入层的部分或全部信息直接与输出层相连接,简单的特征可以通过捷径(short path)进行学习,复杂的特征则通过深层路径(deep p...

2020-04-20 19:39:00 473

原创 Keras函数式API介绍

参考文献:Géron, Aurélien. Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems. O'Reilly Media, 2019.Keras的Sequential顺序模型可...

2020-04-20 19:37:00 229

原创 Keras通过子类(subclass)自定义神经网络模型

参考文献:Géron, Aurélien. Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems. Reilly Media, 2019.除了使用函数API外,还可以通过子类(subc...

2020-04-20 19:33:00 581

原创 R语言kohonen包主要函数介绍

最近准备写一篇关于自组织映射 (Self-organizing map)的文章。SOM的代码很多,研究了一圈之后目前使用最顺手的是R语言的kohonen包。这个kohonen包功能很丰富,但是接口不是特别合理。R语言包大部分是统计学家写的,功能强大,数学上严谨,但是不怎么考虑代码的规范和简洁。kohonen最重要的四个函数:somxyfsupersomsomgrid这个...

2020-04-20 19:24:00 1915

原创 在Shell直接运行Python命令并显示

python -c 'print("Hi")'Hi

2020-04-15 20:43:00 943

原创 欧拉距离(Euclidean distance)

a=[2400,156000]b=[1950,126750]np.linalg.norm(a-b)29253.461333661013a=[240,15600]b=[195,12675]np.linalg.norm(a-b)2925.346133366101Additionally, Euclidean distance multiplies the effect of ...

2020-04-15 20:41:00 2013

原创 R split data into tran/test sets

require(caTools)set.seed(101) sample = sample.split(data$anycolumn, SplitRatio = .75)train = subset(data, sample == TRUE)test = subset(data, sample == FALSE)

2020-04-15 14:53:00 61

原创 R reverse color map

# reverse color rampcolors <- function(n, alpha = 1) { rev(heat.colors(n, alpha))}plot(NBA.SOM1, type = "counts", palette.name = colors, heatkey = TRUE)

2020-04-14 18:32:00 119 1

原创 Pandas groupby sample

frac = .3df.groupby('b').apply(pd.DataFrame.sample, frac=.3) a bb 0 6 7 01 0 1 1df.groupby('b', group_keys=False).apply(pd.DataFrame.sample, frac=.3) a b6 7 02 3 ...

2020-04-13 21:19:00 840

原创 GitHub Pages

https://github.com/pages-themes/cayman/issues/29Disabling the "View on GitHub" buttongithub: is_project_page: false

2020-04-09 18:31:00 148

原创 minisom学习笔记

plt.pcolor(som.distance_map().T, cmap='bone_r') # plotting the distance map as background这里的转置.T只是为了使得distnace小的地方颜色深,大的地方深色浅。

2020-04-09 18:30:00 1614

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除