AI大模型千问 qwen 中文文档model-00003-of-00004.safetensor │ │ ├── model-00004-of-00004.safetensor │ │ ├── model.safetensor.index.json │ │ ├── merges.txt │ │ ├── tokenizer_config.json │ │ └── vocab.json 随后你需要运行 python server.py 为实现检索增强生成(RAG),我们建议您首先安装与 LlamaIndex 相关的软件包。 以下是一个简单的代码示例: pip install llama-index pip install llama-index-llms-huggingface pip install llama-index-readers-web 1.15.2 设置参数 Now we can set up LLM, embedding model import torch from llama_index.core import Settings from llama_index.core.node_parser import SentenceSplitter from llama_index.llms.huggingface import HuggingFaceLLM from llama_index.embeddings.huggingface0 码力 | 56 页 | 835.78 KB | 1 年前3
机器学习课程-温州大学-时间序列总结to_datetime('20180828') 9 创建时间序列 如果传入的是多个datetime组成的列表,则Pandas会 将其强制转换为DatetimeIndex类对象。 date_index = pd.to_datetime(['20180820','20180828', '20180908']) DatetimeIndex(['2018-08-20', '2018-08-28' 时间戳为索引的Series对象。 date_ser = pd.Series([11, 22, 33], index=date_index) 2018-08-20 11 2018-08-28 22 2018-09-08 33 11 创建时间序列 还可以将包含多个datetime对象的列表传给 index参数,同样能创建具有时间戳索引的 Series对象。 date_list = [datetime(2018 [datetime(2018, 1, 1), datetime(2018, 1, 15] time_se = pd.Series(np.arange(6), index=date_list) 12 创建时间序列 如果希望DataFrame对象具有时间戳索引, 也可以采用上述方式进行创建。 data_demo = [[11, 22, 33], [44, 55, 66]] date_list = [datetime(20180 码力 | 67 页 | 1.30 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 4 - Efficient Architectureswill start with creating a vocabulary of words in the first step. The second step assigns a unique index to the words. This process is called vectorization. An embedding table with a row for each word is vocabulary. If a word doesn’t exist in the vocabulary, we map it to the index of the OOV token. Similarly, we replace the label word with the index of that word in the vocabulary. Refer to Figure 4-7 for visualizing 3. The model takes as input to produce a probability vector of size . The index with highest probability indicates the index of the hidden word. Refer to Figure 4-9 for a visual depiction of the above0 码力 | 53 页 | 3.92 MB | 1 年前3
【PyTorch深度学习-龙龙老师】-测试版202112zeros(label.size(0), depth) idx = torch.LongTensor(label).view(-1, 1) out.scatter_(dim=1, index=idx, value=1) return out y = torch.tensor([0,1,2,3]) # 数字编码的 4 个样本标签 预览版202112 3.3 误差计算 5, 6, 7, 7]) 5.6 高级操作 上述介绍的操作函数大部分是常有并且容易理解的,接下来将介绍部分常用,但是稍 复杂的功能函数。 5.6.1 索引采样 torch.index_select()函数可以实现根据索引号收集数据的目的。考虑班级成绩册的例 子,假设共有 4 个班级,每个班级 35 个学生,8 门科目,则保存成绩册的张量 shape 为 [4,35,8]。随机创建张量如下: 个班级的成绩册,可以给定需要收集班级的索引号:[0,1],并指定班 级的维度 dim=0,通过 torch.index_select()函数收集数据,代码如下: In [38]: # 选择班级维度的 0,1 号班级 out = torch.index_select(x, dim=0, index=torch.tensor([0,1])) out.shape Out[38]: torch0 码力 | 439 页 | 29.91 MB | 1 年前3
Keras: 基于 Python 的深度学习库multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `get_output_at(node_index)` instead. 好吧,通过下面的方法可以解决: assert lstm.get_output_at(0) == encoded_a assert lstm.get_output_at(1) 数组。 4.2.3.11 get_layer get_layer(self, name=None, index=None) 提取模型的某一层。 根据网络层的名称(唯一)或其索引返回该层。索引是基于水平图遍历的顺序(自下而上)。 参数 • name: 字符串,层的名字。 • index: 整数,层的索引。 返回 一个层实例。 模型 49 4.3 函数式 API 4.3.1 Model 如果生成器生成的数据格式不正确。 4.3.3.11 get_layer get_layer(self, name=None, index=None) 根据名称(唯一)或索引值查找网络层。 索引值来自于水平图遍历的顺序(自下而上)。 参数 • name: 字符串,层的名字。 • index: 整数,层的索引。 返回 一个层实例。 异常 • ValueError: 如果层的名称或索引不正确。 关于0 码力 | 257 页 | 1.19 MB | 1 年前3
机器学习课程-温州大学-numpy使用总结unique有两个参数,return_index=True同时返回原始数组中 的下标,return_inverse=True表示原始数据在新数组的下标 。 > x, index = np.unique(a, return_index=True)] x index a[index] ------------------0 码力 | 49 页 | 1.52 MB | 1 年前3
动手学深度学习 v2.0若无法获得测试数据,则可根据训练数据计算均值和标准差 numeric_features = all_features.dtypes[all_features.dtypes != 'object'].index all_features[numeric_features] = all_features[numeric_features].apply( lambda x: (x - x.mean()) pd.concat([test_data['Id'], test_data['SalePrice']], axis=1) submission.to_csv('submission.csv', index=False) 如果测试集上的预测与K倍交叉验证过程中的预测相似,那就是时候把它们上传到Kaggle了。下面的代码将 生成一个名为submission.csv的文件。 train_and_pred(train_features device('cuda'), torch.device('cuda:1') (device(type='cpu'), device(type='cuda'), device(type='cuda', index=1)) 我们可以查询可用gpu的数量。 212 5. 深度学习计算 torch.cuda.device_count() 2 现在我们定义了两个方便的函数,这两个函数允许我们在不存在所需所有GPU的情况下运行代码。0 码力 | 797 页 | 29.45 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 7 - AutomationCHILD_PARAMS['blocks'], len(STATE_ID_TO_STATE_SPACE_ID) ) TIMESTEP_ADDRESSES = np.stack( np.unravel_index(range(TOTAL_TIMESTEPS),TIMESTEP_ADDRESS_SPACE), -1 ) STATE_ADDRESSES = list(map( lambda x: [x[0] = 0. for index, output in enumerate(outputs): y_true = [child_config[index]] loss += self.loss_fn(y_true, output) grads = tape.gradient(loss, controller.rnn.trainable_variables) for index, grad in enumerate(grads): enumerate(grads): grads[index] = tf.multiply(grad, reward) self.optimizer.apply_gradients( zip(grads, controller.rnn.trainable_variables) ) The next chunk of code puts everything together and runs0 码力 | 33 页 | 2.48 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 5 - Advanced Compression Techniquesscenario, we can list all the centroids in a codebook and replace each element in our tensor with the index of the centroid in the codebook closest to that element. The decoding process simply requires replacing centroid indices in the encoded tensor by looking up the value of the respective centroid at that index in the codebook. If we had centroids that took bytes each (typically for floating point values), the codebook will cost us bytes to store. For each tensor element we will now store only the index of its centroid in the codebook, which will only take up bits. For a tensor with elements, the cost0 码力 | 34 页 | 3.18 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 2 - Compression TechniquesWe use the sparse variant of the categorical cross entropy loss function so that we can use the index of the correct class for each example. The regular function expects one-hot labels which would require interpreter. interpreter.set_tensor(input_details[0]['index'], input_data) interpreter.invoke() output_data = interpreter.get_tensor(output_details[0]['index']) # The returned output is a tensor of logits output is a quantized (for quantized models) logits tensor. We compute the accuracy by finding the index of the logits tensor which has the highest value. It works well with both, the quantized or the regular0 码力 | 33 页 | 1.96 MB | 1 年前3
共 28 条
- 1
- 2
- 3













