《Efficient Deep Learning Book》[EDL] Chapter 5 - Advanced Compression Techniquescentroids. distances = tf.subtract(tf.reshape(x_var, (-1, 1)), centroids_var) ** 2 best_distances = tf.math.reduce_min(distances, axis=1) return tf.reduce_mean(best_distances) Now we can implement the method (-1, 1)), centroids) ** 2 # Now compute the distance to the closest centroid. best_distances = tf.math.reduce_min(distances, axis=1) # Create an indicator variable matrix, where 1.0 at index [i][j] denotes reshape(best_distances, (-1, 1))), dtype=tf.float64) # Now lookup the centroid indices. encoded_x_flattened = tf.math.argmax(is_closest, axis=1) # Finally, reshape the array to the original shape. return tf.reshap0 码力 | 34 页 | 3.18 MB | 1 年前3
动手学深度学习 v2.0中提供了这 些函数和类的详细描述。d2l软件包是轻量级的,仅需要以下软件包和模块作为依赖项: #@save import collections import hashlib import math import os import random import re import shutil import sys import tarfile import time import 在训练我们的模型时,我们经常希望能够同时处理整个小批量的样本。为了实现这一点,需要我们对计算进 行矢量化,从而利用线性代数库,而不是在Python中编写开销高昂的for循环。 %matplotlib inline import math import time import numpy as np import torch from d2l import torch as d2l 为了说明矢量化为什么如此重要,我们考虑 1 2σ2 (x − µ)2 � . (3.1.11) 下面我们定义一个Python函数来计算正态分布。 def normal(x, mu, sigma): p = 1 / math.sqrt(2 * math.pi * sigma**2) return p * np.exp(-0.5 / sigma**2 * (x - mu)**2) 我们现在可视化正态分布。 # 再次使用numpy进行可视化0 码力 | 797 页 | 29.45 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.17.0strftime * total_seconds – Period Frequency Enhancement – Support for SAS XPORT files – Support for Math Functions in .eval() – Changes to Excel with MultiIndex – Google BigQuery Enhancements – Display Alignment details. Support for Math Functions in .eval() eval() now supports calling math functions (GH4893) df = pd.DataFrame({'a': np.random.randn(10)}) df.eval("b = sin(a)") The support math functions are sin multi-index with xs, method #2 In [72]: index = list(itertools.product(['Ada','Quinn','Violet'],['Comp','Math','Sci'])) In [73]: headr = list(itertools.product(['Exams','Labs'],['I','II'])) In [74]: indx =0 码力 | 1787 页 | 10.76 MB | 1 年前3
机器学习课程-温州大学-numpy使用总结42787610e-01, 9.84807753e-01, . . . . . , -2.44929360e-16]) 值得注意的是,对于同等长度的ndarray,np.sin()比math.sin()快 但是对于单个数值,math.sin()的速度则更快。 25 四则运算 NumPy提供了许多ufunc函数,它们和相应的运算符运算结果相同。 > a = np.arange(0, 4) > b =0 码力 | 49 页 | 1.52 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.19.0SAS XPORT files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Support for Math Functions in .eval() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Changes to Excel strftime * total_seconds – Period Frequency Enhancement – Support for SAS XPORT files – Support for Math Functions in .eval() – Changes to Excel with MultiIndex – Google BigQuery Enhancements – Display details. Support for Math Functions in .eval() eval() now supports calling math functions (GH4893) df = pd.DataFrame({'a': np.random.randn(10)}) df.eval("b = sin(a)") The support math functions are sin0 码力 | 1937 页 | 12.03 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.19.1SAS XPORT files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Support for Math Functions in .eval() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Changes to Excel strftime * total_seconds – Period Frequency Enhancement – Support for SAS XPORT files – Support for Math Functions in .eval() – Changes to Excel with MultiIndex – Google BigQuery Enhancements – Display chunksize=10000) do_something(df) See the docs for more details. Support for Math Functions in .eval() eval() now supports calling math functions (GH4893) 1.6. v0.17.0 (October 9, 2015) 103 pandas: powerful0 码力 | 1943 页 | 12.06 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.20.3SAS XPORT files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 1.10.1.7 Support for Math Functions in .eval() . . . . . . . . . . . . . . . . . . . . . . . . . 151 1.10.1.8 Changes to Excel strftime * total_seconds – Period Frequency Enhancement – Support for SAS XPORT files – Support for Math Functions in .eval() – Changes to Excel with MultiIndex – Google BigQuery Enhancements – Display 10.1.7 Support for Math Functions in .eval() eval() now supports calling math functions (GH4893) df = pd.DataFrame({'a': np.random.randn(10)}) df.eval("b = sin(a)") The support math functions are sin0 码力 | 2045 页 | 9.18 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.20.2SAS XPORT files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 1.9.1.7 Support for Math Functions in .eval() . . . . . . . . . . . . . . . . . . . . . . . . . 149 1.9.1.8 Changes to Excel strftime * total_seconds – Period Frequency Enhancement – Support for SAS XPORT files – Support for Math Functions in .eval() – Changes to Excel with MultiIndex – Google BigQuery Enhancements – Display 9.1.7 Support for Math Functions in .eval() eval() now supports calling math functions (GH4893) df = pd.DataFrame({'a': np.random.randn(10)}) df.eval("b = sin(a)") The support math functions are sin0 码力 | 1907 页 | 7.83 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.21.1SAS XPORT files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 1.12.1.7 Support for Math Functions in .eval() . . . . . . . . . . . . . . . . . . . . . . . . . 180 1.12.1.8 Changes to Excel strftime * total_seconds – Period Frequency Enhancement – Support for SAS XPORT files – Support for Math Functions in .eval() – Changes to Excel with MultiIndex – Google BigQuery Enhancements – Display 12.1.7 Support for Math Functions in .eval() eval() now supports calling math functions (GH4893) df = pd.DataFrame({'a': np.random.randn(10)}) df.eval("b = sin(a)") The support math functions are sin0 码力 | 2207 页 | 8.59 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 7 - Automationiteration in range(2000): with tf.GradientTape() as tape: output = model(X) loss = tf.reduce_mean(tf.math.square(Y - output)) grads = tape.gradient(loss, model.trainable_variables) opt.apply_gradients(zip(grads import layers, optimizers from collections import deque from matplotlib.ticker import MaxNLocator from math import pow SEED = 111 tf.random.set_seed(SEED) np.random.seed(SEED) random.seed(SEED) We will need0 码力 | 33 页 | 2.48 MB | 1 年前3
共 98 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10













