《Efficient Deep Learning Book》[EDL] Chapter 4 - Efficient Architecturesimport pprint class_names = open(os.path.join('dbpedia_csv', 'classes.txt')).read().splitlines() num_classes = len(class_names) # The classes are as follows. pprint.pprint(class_names) There are fourteen end_to_end_model.predict( [['Usain Bolt is a very well known sprinter and Olympic medal winner.']] ) class_names[np.argmax(probabilities[0])] 'Athlete' It works! It’s been quite a journey, let's pause and ponder loading the necessary modules. The Oxford-IIIT dataset is available through the tensorflow_datasets package. We apply the standard preprocessing routines to resize and normalize the images. import tensorflow0 码力 | 53 页 | 3.92 MB | 1 年前3
PyTorch Release Noteslater R515), 525.85 (or later R525), or 530.30 (or later R530). The CUDA driver's compatibility package only supports particular drivers. Thus, users should upgrade from all R418, R440, R460, and R520 manually install a Conda package manager, and add the conda path to your PYTHONPATH for example, using export PYTHONPATH="/opt/conda/lib/python3.8/site-packages" if your Conda package manager was installed later R515), 525.85 (or later R525), or 530.30 (or later R530). The CUDA driver's compatibility package only supports particular drivers. Thus, users should upgrade from all R418, R440, R460, and R5200 码力 | 365 页 | 2.94 MB | 1 年前3
Keras: 基于 Python 的深度学习库None。声明评估结束之前的总步数(批次样本)。默认值 None。 模型 44 返回 标量测试误差(如果模型没有评估指标)或标量列表(如果模型计算其他指标)。属性 model.metrics_names 将提供标量输出的显示标签。 异常 • RuntimeError: 如果模型从未编译。 4.2.3.4 predict predict(self, x, batch_size=None, verbose=0 失函数。 • sample_weight: 样本权重,Numpy 数组。 返回 标量训练误差(如果模型没有评估指标)或标量列表(如果模型计算其他指标)。属性 model.metrics_names 将提供标量输出的显示标签。 异常 • RuntimeError: 如果模型从未编译。 模型 45 4.2.3.6 test_on_batch test_on_batch(self, x 标签,Numpy 数组。 • sample_weight: 样本权重,Numpy 数组。 返回 标量测试误差(如果模型没有评估指标)或标量列表(如果模型计算其他指标)。属性 model.metrics_names 将提供标量输出的显示标签。 异常 • RuntimeError: 如果模型从未编译。 4.2.3.7 predict_on_batch predict_on_batch(self, x)0 码力 | 257 页 | 1.19 MB | 1 年前3
《TensorFlow 2项目进阶实战》2-快速上手篇:动⼿训练模型和部署服务plt.imshow(train_images[1]) plt.colorbar() plt.grid(False) plt.show() Preprocess data class_names = [ 'T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat’, 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle yticks ( [ ] ) plt.grid(False) plt.imshow(train_images[i],camp=plt.cm.binary) plt.xlabel(class_names(train_labels[i])) plt.show( ) Build the model Train and evaluate Make prediction Visualize prediction0 码力 | 52 页 | 7.99 MB | 1 年前3
AI大模型千问 qwen 中文文档{} maybe_lora_bias = {} lora_bias_names = set() for k, t in named_params: if "lora_" in k: to_return[k] = t bias_name = k.split("lora_")[0] + "bias" lora_bias_names.add(bias_name) elif "bias" in k: maybe_lora_bias[k] maybe_lora_bias[k] = t for k, t in maybe_lora_bias: if bias_name in lora_bias_names: to_return[bias_name] = t else: raise NotImplementedError to_return = {k: maybe_zero_3(v) for k, v in to_return0 码力 | 56 页 | 835.78 KB | 1 年前3
动手学深度学习 v2.0'__all__', '__ �→builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', �→ '__spec__', 'bernoulli', 'beta', 'biject_to', 'binomial', 'categorical', 'cauchy' https://discuss.d2l.ai/t/1822 71 https://archive.ics.uci.edu/ml/machine‐learning‐databases/housing/housing.names 180 4. 多层感知机 def download(name, cache_dir=os.path.join('..', 'data')): #@save """下载一个DATA_HUB中的文件,返回本地文件名""" nn.Linear: nn.init.xavier_uniform_(m.weight) if type(m) == nn.GRU: for param in m._flat_weights_names: if "weight" in param: nn.init.xavier_uniform_(m._parameters[param]) net.apply(xavier_init_weights)0 码力 | 797 页 | 29.45 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 5 - Advanced Compression Techniquesuntouched. We define a create_model_for_pruning() function which takes a pre-trained model and the names of the prunable blocks as inputs. It returns a model that is capable of sparse training. It clones prepares the input arguments to create a model for pruning. The prunable_blocks variable is the list of names of prunable convolution blocks. We prune all convolution blocks from second (zero indexed) onwards0 码力 | 34 页 | 3.18 MB | 1 年前3
PyTorch Tutorialtorch.cuda.FloatTensor *Assume 't' is a tensor Autograd • Autograd • Automatic Differentiation Package • Don’t need to worry about partial differentiation, chain rule etc.. • backward() does that • loss a tensor Autograd (continued) • Manual Weight Update - example Optimizer • Optimizers (optim package) • Adam, Adagrad, Adadelta, SGD etc.. • Manually updating is ok if small number of weights • Imagine0 码力 | 38 页 | 4.09 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 3 - Learning Techniquesnotebook here. Tensorflow provides easy access to this dataset through the tensorflow-datasets package. Let’s start by loading the training and validation splits of the dataset. The make_dataset() function keras.losses as losses We will install the pydub dependency required by the tensorflow_datasets package for processing audio data, and load the speech_commands dataset from TFDS. !pip install pydub data_ds0 码力 | 56 页 | 18.93 MB | 1 年前3
Machine Learning Pytorch Tutorialfor more information on data types. Tensors – PyTorch v.s. NumPy ● Many functions have the same names as well PyTorch NumPy x.reshape / x.view x.reshape x.squeeze() x.squeeze() x.unsqueeze(1) np.expand_dims(x0 码力 | 48 页 | 584.86 KB | 1 年前3
共 16 条
- 1
- 2













