super(channel_selection, self).__init__() self.indexes = nn.Parameter(torch.ones(num_channels))

时间: 2024-05-23 21:15:53 浏览: 166
这两行代码是一个类的构造函数,用于初始化类的属性。第一行代码调用了父类的构造函数并传递了 `channel_selection` 参数,以便父类可以正确地初始化。第二行代码创建了一个名为 `indexes` 的可训练参数(`nn.Parameter`),它是一个大小为 `num_channels` 的张量,每个元素都被初始化为 1。这个参数在模型训练时会被动态更新,用于选择输入数据中的哪些通道参与计算。
相关问题

def forward(self, data, org_edge_index): x = data.clone().detach() edge_index_sets = self.edge_index_sets device = data.device batch_num, node_num, all_feature = x.shape x = x.view(-1, all_feature).contiguous() gcn_outs = [] for i, edge_index in enumerate(edge_index_sets): edge_num = edge_index.shape[1] cache_edge_index = self.cache_edge_index_sets[i] if cache_edge_index is None or cache_edge_index.shape[1] != edge_num*batch_num: self.cache_edge_index_sets[i] = get_batch_edge_index(edge_index, batch_num, node_num).to(device) batch_edge_index = self.cache_edge_index_sets[i] all_embeddings = self.embedding(torch.arange(node_num).to(device)) weights_arr = all_embeddings.detach().clone() all_embeddings = all_embeddings.repeat(batch_num, 1) weights = weights_arr.view(node_num, -1) cos_ji_mat = torch.matmul(weights, weights.T) normed_mat = torch.matmul(weights.norm(dim=-1).view(-1,1), weights.norm(dim=-1).view(1,-1)) cos_ji_mat = cos_ji_mat / normed_mat dim = weights.shape[-1] topk_num = self.topk topk_indices_ji = torch.topk(cos_ji_mat, topk_num, dim=-1)[1] self.learned_graph = topk_indices_ji gated_i = torch.arange(0, node_num).T.unsqueeze(1).repeat(1, topk_num).flatten().to(device).unsqueeze(0) gated_j = topk_indices_ji.flatten().unsqueeze(0) gated_edge_index = torch.cat((gated_j, gated_i), dim=0) batch_gated_edge_index = get_batch_edge_index(gated_edge_index, batch_num, node_num).to(device) gcn_out = self.gnn_layers[i](x, batch_gated_edge_index, node_num=node_num*batch_num, embedding=all_embeddings) gcn_outs.append(gcn_out) x = torch.cat(gcn_outs, dim=1) x = x.view(batch_num, node_num, -1) indexes = torch.arange(0,node_num).to(device) out = torch.mul(x, self.embedding(indexes)) out = out.permute(0,2,1) out = F.relu(self.bn_outlayer_in(out)) out = out.permute(0,2,1) out = self.dp(out) out = self.out_layer(out) out = out.view(-1, node_num) return out

这是一个PyTorch模型的前向传播函数,它接受两个参数:data和org_edge_index。该函数使用GCN(图卷积神经网络)来处理输入数据,并返回一个输出张量。具体实现细节可以参考代码中的注释。

class AbstractGreedyAndPrune(): def __init__(self, aoi: AoI, uavs_tours: dict, max_rounds: int, debug: bool = True): self.aoi = aoi self.max_rounds = max_rounds self.debug = debug self.graph = aoi.graph self.nnodes = self.aoi.n_targets self.uavs = list(uavs_tours.keys()) self.nuavs = len(self.uavs) self.uavs_tours = {i: uavs_tours[self.uavs[i]] for i in range(self.nuavs)} self.__check_depots() self.reachable_points = self.__reachable_points() def __pruning(self, mr_solution: MultiRoundSolution) -> MultiRoundSolution: return utility.pruning_multiroundsolution(mr_solution) def solution(self) -> MultiRoundSolution: mrs_builder = MultiRoundSolutionBuilder(self.aoi) for uav in self.uavs: mrs_builder.add_drone(uav) residual_ntours_to_assign = {i : self.max_rounds for i in range(self.nuavs)} tour_to_assign = self.max_rounds * self.nuavs visited_points = set() while not self.greedy_stop_condition(visited_points, tour_to_assign): itd_uav, ind_tour = self.local_optimal_choice(visited_points, residual_ntours_to_assign) residual_ntours_to_assign[itd_uav] -= 1 tour_to_assign -= 1 opt_tour = self.uavs_tours[itd_uav][ind_tour] visited_points |= set(opt_tour.targets_indexes) # update visited points mrs_builder.append_tour(self.uavs[itd_uav], opt_tour) return self.__pruning(mrs_builder.build()) class CumulativeGreedyCoverage(AbstractGreedyAndPrune): choice_dict = {} for ind_uav in range(self.nuavs): uav_residual_rounds = residual_ntours_to_assign[ind_uav] if uav_residual_rounds > 0: uav_tours = self.uavs_tours[ind_uav] for ind_tour in range(len(uav_tours)): tour = uav_tours[ind_tour] quality_tour = self.evaluate_tour(tour, uav_residual_rounds, visited_points) choice_dict[quality_tour] = (ind_uav, ind_tour) best_value = max(choice_dict, key=int) return choice_dict[best_value] def evaluate_tour(self, tour : Tour, round_count : int, visited_points : set): new_points = (set(tour.targets_indexes) - visited_points) return round_count * len(new_points) 如何改写上述程序,使其能返回所有已经探索过的目标点visited_points的数量,请用代码表示

可以在 `solution()` 方法中添加一个变量来记录已经探索过的目标点数量,然后在每次更新 `visited_points` 后更新这个变量。下面是修改后的代码: ``` class AbstractGreedyAndPrune(): def __init__(self, aoi: AoI, uavs_tours: dict, max_rounds: int, debug: bool = True): self.aoi = aoi self.max_rounds = max_rounds self.debug = debug self.graph = aoi.graph self.nnodes = self.aoi.n_targets self.uavs = list(uavs_tours.keys()) self.nuavs = len(self.uavs) self.uavs_tours = {i: uavs_tours[self.uavs[i]] for i in range(self.nuavs)} self.__check_depots() self.reachable_points = self.__reachable_points() def __pruning(self, mr_solution: MultiRoundSolution) -> MultiRoundSolution: return utility.pruning_multiroundsolution(mr_solution) def solution(self) -> Tuple[MultiRoundSolution, int]: mrs_builder = MultiRoundSolutionBuilder(self.aoi) for uav in self.uavs: mrs_builder.add_drone(uav) residual_ntours_to_assign = {i : self.max_rounds for i in range(self.nuavs)} tour_to_assign = self.max_rounds * self.nuavs visited_points = set() explored_points = 0 while not self.greedy_stop_condition(visited_points, tour_to_assign): itd_uav, ind_tour = self.local_optimal_choice(visited_points, residual_ntours_to_assign) residual_ntours_to_assign[itd_uav] -= 1 tour_to_assign -= 1 opt_tour = self.uavs_tours[itd_uav][ind_tour] new_points = set(opt_tour.targets_indexes) - visited_points explored_points += len(new_points) visited_points |= new_points # update visited points mrs_builder.append_tour(self.uavs[itd_uav], opt_tour) return self.__pruning(mrs_builder.build()), explored_points class CumulativeGreedyCoverage(AbstractGreedyAndPrune): def evaluate_tour(self, tour : Tour, round_count : int, visited_points : set): new_points = set(tour.targets_indexes) - visited_points return round_count * len(new_points) def local_optimal_choice(self, visited_points, residual_ntours_to_assign): choice_dict = {} for ind_uav in range(self.nuavs): uav_residual_rounds = residual_ntours_to_assign[ind_uav] if uav_residual_rounds > 0: uav_tours = self.uavs_tours[ind_uav] for ind_tour in range(len(uav_tours)): tour = uav_tours[ind_tour] quality_tour = self.evaluate_tour(tour, uav_residual_rounds, visited_points) choice_dict[quality_tour] = (ind_uav, ind_tour) best_value = max(choice_dict, key=int) return choice_dict[best_value]
阅读全文

相关推荐

class SVDRecommender: def __init__(self, k=50, ncv=None, tol=0, which='LM', v0=None, maxiter=None, return_singular_vectors=True, solver='arpack'): self.k = k self.ncv = ncv self.tol = tol self.which = which self.v0 = v0 self.maxiter = maxiter self.return_singular_vectors = return_singular_vectors self.solver = solver def svds(self, A): if self.which == 'LM': largest = True elif self.which == 'SM': largest = False else: raise ValueError("which must be either 'LM' or 'SM'.") if not (isinstance(A, LinearOperator) or isspmatrix(A) or is_pydata_spmatrix(A)): A = np.asarray(A) n, m = A.shape if self.k <= 0 or self.k >= min(n, m): raise ValueError("k must be between 1 and min(A.shape), k=%d" % self.k) if isinstance(A, LinearOperator): if n > m: X_dot = A.matvec X_matmat = A.matmat XH_dot = A.rmatvec XH_mat = A.rmatmat else: X_dot = A.rmatvec X_matmat = A.rmatmat XH_dot = A.matvec XH_mat = A.matmat dtype = getattr(A, 'dtype', None) if dtype is None: dtype = A.dot(np.zeros([m, 1])).dtype else: if n > m: X_dot = X_matmat = A.dot XH_dot = XH_mat = _herm(A).dot else: XH_dot = XH_mat = A.dot X_dot = X_matmat = _herm(A).dot def matvec_XH_X(x): return XH_dot(X_dot(x)) def matmat_XH_X(x): return XH_mat(X_matmat(x)) XH_X = LinearOperator(matvec=matvec_XH_X, dtype=A.dtype, matmat=matmat_XH_X, shape=(min(A.shape), min(A.shape))) #获得隐式定义的格拉米矩阵的低秩近似。 eigvals, eigvec = eigsh(XH_X, k=self.k, tol=self.tol ** 2, maxiter=self.maxiter, ncv=self.ncv, which=self.which, v0=self.v0) #格拉米矩阵有实非负特征值。 eigvals = np.maximum(eigvals.real, 0) #使用来自pinvh的小特征值的复数检测。 t = eigvec.dtype.char.lower() factor = {'f': 1E3, 'd': 1E6} cond = factor[t] * np.finfo(t).eps cutoff = cond * np.max(eigvals) #获得一个指示哪些本征对不是简并微小的掩码, #并为阈值奇异值创建一个重新排序数组。 above_cutoff = (eigvals > cutoff) nlarge = above_cutoff.sum() nsmall = self.k - nlarge slarge = np.sqrt(eigvals[above_cutoff]) s = np.zeros_like(eigvals) s[:nlarge] = slarge if not self.return_singular_vectors: return np.sort(s) if n > m: vlarge = eigvec[:, above_cutoff] ularge = X_matmat(vlarge) / slarge if self.return_singular_vectors != 'vh' else None vhlarge = _herm(vlarge) else: ularge = eigvec[:, above_cutoff] vhlarge = _herm(X_matmat(ularge) / slarge) if self.return_singular_vectors != 'u' else None u = _augmented_orthonormal_cols(ularge, nsmall) if ularge is not None else None vh = _augmented_orthonormal_rows(vhlarge, nsmall) if vhlarge is not None else None indexes_sorted = np.argsort(s) s = s[indexes_sorted] if u is not None: u = u[:, indexes_sorted] if vh is not None: vh = vh[indexes_sorted] return u, s, vh def _augmented_orthonormal_cols(U, n): if U.shape[0] <= n: return U Q, R = np.linalg.qr(U) return Q[:, :n] def _augmented_orthonormal_rows(V, n): if V.shape[1] <= n: return V Q, R = np.linalg.qr(V.T) return Q[:, :n].T def _herm(x): return np.conjugate(x.T) 将上述代码修改为使用LM,迭代器使用arpack

from scipy.sparse.linalg import eigsh, LinearOperator from scipy.sparse import isspmatrix, is_pydata_spmatrix class SVDRecommender: def init(self, k=50, ncv=None, tol=0, which='LM', v0=None, maxiter=None, return_singular_vectors=True, solver='arpack'): self.k = k self.ncv = ncv self.tol = tol self.which = which self.v0 = v0 self.maxiter = maxiter self.return_singular_vectors = return_singular_vectors self.solver = solver def svds(self, A): largest = self.which == 'LM' if not largest and self.which != 'SM': raise ValueError("which must be either 'LM' or 'SM'.") if not (isinstance(A, LinearOperator) or isspmatrix(A) or is_pydata_spmatrix(A)): A = np.asarray(A) n, m = A.shape if self.k <= 0 or self.k >= min(n, m): raise ValueError("k must be between 1 and min(A.shape), k=%d" % self.k) if isinstance(A, LinearOperator): if n > m: X_dot = A.matvec X_matmat = A.matmat XH_dot = A.rmatvec XH_mat = A.rmatmat else: X_dot = A.rmatvec X_matmat = A.rmatmat XH_dot = A.matvec XH_mat = A.matmat dtype = getattr(A, 'dtype', None) if dtype is None: dtype = A.dot(np.zeros([m, 1])).dtype else: if n > m: X_dot = X_matmat = A.dot XH_dot = XH_mat = _herm(A).dot else: XH_dot = XH_mat = A.dot X_dot = X_matmat = _herm(A).dot def matvec_XH_X(x): return XH_dot(X_dot(x)) def matmat_XH_X(x): return XH_mat(X_matmat(x)) XH_X = LinearOperator(matvec=matvec_XH_X, dtype=A.dtype, matmat=matmat_XH_X, shape=(min(A.shape), min(A.shape))) eigvals, eigvec = eigsh(XH_X, k=self.k, tol=self.tol ** 2, maxiter=self.maxiter, ncv=self.ncv, which=self.which, v0=self.v0) eigvals = np.maximum(eigvals.real, 0) t = eigvec.dtype.char.lower() factor = {'f': 1E3, 'd': 1E6} cond = factor[t] * np.finfo(t).eps cutoff = cond * np.max(eigvals) above_cutoff = (eigvals > cutoff) nlarge = above_cutoff.sum() nsmall = self.k - nlarge slarge = np.sqrt(eigvals[above_cutoff]) s = np.zeros_like(eigvals) s[:nlarge] = slarge if not self.return_singular_vectors: return np.sort(s) if n > m: vlarge = eigvec[:, above_cutoff] ularge = X_matmat(vlarge) / slarge if self.return_singular_vectors != 'vh' else None vhlarge = _herm(vlarge) else: ularge = eigvec[:, above_cutoff] vhlarge = _herm(X_matmat(ularge) / slarge) if self.return_singular_vectors != 'u' else None u = _augmented_orthonormal_cols(ularge, nsmall) if ularge is not None else None vh = _augmented_orthonormal_rows(vhlarge, nsmall) if vhlarge is not None else None indexes_sorted = np.argsort(s) s = s[indexes_sorted] if u is not None: u = u[:, indexes_sorted] if vh is not None: vh = vh[indexes_sorted] return u, s, vh def _augmented_orthonormal_cols(U, n): if U.shape[0] <= n: return U Q, R = np.linalg.qr(U) return Q[:, :n] def _augmented_orthonormal_rows(V, n): if V.shape[1] <= n: return V Q, R = np.linalg.qr(V.T) return Q[:, :n].T def _herm(x): return np.conjugate(x.T)这段代码中使用的scipy包太旧了,导致会出现报错信息为:cannot import name 'is_pydata_spmatrix' from 'scipy.sparse' (D:\Anaconda\lib\site-packages\scipy\sparse_init.py),将这段代码修改为使用最新版的scipy包

class SVDRecommender: def init(self, k=50, ncv=None, tol=0, which='LM', v0=None, maxiter=None, return_singular_vectors=True, solver='arpack'): self.k = k self.ncv = ncv self.tol = tol self.which = which self.v0 = v0 self.maxiter = maxiter self.return_singular_vectors = return_singular_vectors self.solver = solver def svds(self, A): if which == 'LM': largest = True elif which == 'SM': largest = False else: raise ValueError("which must be either 'LM' or 'SM'.") if not (isinstance(A, LinearOperator) or isspmatrix(A) or is_pydata_spmatrix(A)): A = np.asarray(A) n, m = A.shape if k <= 0 or k >= min(n, m): raise ValueError("k must be between 1 and min(A.shape), k=%d" % k) if isinstance(A, LinearOperator): if n > m: X_dot = A.matvec X_matmat = A.matmat XH_dot = A.rmatvec XH_mat = A.rmatmat else: X_dot = A.rmatvec X_matmat = A.rmatmat XH_dot = A.matvec XH_mat = A.matmat dtype = getattr(A, 'dtype', None) if dtype is None: dtype = A.dot(np.zeros([m, 1])).dtype else: if n > m: X_dot = X_matmat = A.dot XH_dot = XH_mat = _herm(A).dot else: XH_dot = XH_mat = A.dot X_dot = X_matmat = _herm(A).dot def matvec_XH_X(x): return XH_dot(X_dot(x)) def matmat_XH_X(x): return XH_mat(X_matmat(x)) XH_X = LinearOperator(matvec=matvec_XH_X, dtype=A.dtype, matmat=matmat_XH_X, shape=(min(A.shape), min(A.shape))) # Get a low rank approximation of the implicitly defined gramian matrix. eigvals, eigvec = eigsh(XH_X, k=k, tol=tol ** 2, maxiter=maxiter, ncv=ncv, which=which, v0=v0) # Gramian matrix has real non-negative eigenvalues. eigvals = np.maximum(eigvals.real, 0) # Use complex detection of small eigenvalues from pinvh. t = eigvec.dtype.char.lower() factor = {'f': 1E3, 'd': 1E6} cond = factor[t] * np.finfo(t).eps cutoff = cond * np.max(eigvals) # Get a mask indicating which eigenpairs are not degenerate tiny, # and create a reordering array for thresholded singular values. above_cutoff = (eigvals > cutoff) nlarge = above_cutoff.sum() nsmall = k - nlarge slarge = np.sqrt(eigvals[above_cutoff]) s = np.zeros_like(eigvals) s[:nlarge] = slarge if not return_singular_vectors: return np.sort(s) if n > m: vlarge = eigvec[:, above_cutoff] ularge = X_matmat(vlarge) / slarge if return_singular_vectors != 'vh' else None vhlarge = _herm(vlarge) else: ularge = eigvec[:, above_cutoff] vhlarge = _herm(X_matmat(ularge) / slarge) if return_singular_vectors != 'u' else None u = _augmented_orthonormal_cols(ularge, nsmall) if ularge is not None else None vh = _augmented_orthonormal_rows(vhlarge, nsmall) if vhlarge is not None else None indexes_sorted = np.argsort(s) s = s[indexes_sorted] if u is not None: u = u[:, indexes_sorted] if vh is not None: vh = vh[indexes_sorted] return u, s, vh将这段代码放入一个.py文件中,用Spyder查看,有报错,可能是缩进有问题,无法被调用,根据这个问题,给出解决办法,给出改正后的完整代码

bs_data = w_data[w_data['波束场景No'] == cross_data['波束场景No'][0]] 报错:Traceback (most recent call last): File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3652, in get_loc return self._engine.get_loc(casted_key) File "pandas\_libs\index.pyx", line 147, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\index.pyx", line 176, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\_libs\hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: '波束场景No' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 127, in <module> data = optimizing() File "D:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 18, in __init__ self.optimizing_main() File "D:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 120, in optimizing_main self.child2=self.mutation_cdata(fitness_data,self.cross_data) File "D:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 86, in mutation_cdata bs_data = w_data[w_data['波束场景No'] == cross_data['波束场景No'][0]] File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 3761, in __getitem__ indexer = self.columns.get_loc(key) File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3654, in get_loc raise KeyError(key) from err KeyError: '波束场景No'

(random.randint(0, bs_data[12]-1))*3+bs_data[8] 报错:Traceback (most recent call last): File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3652, in get_loc return self._engine.get_loc(casted_key) File "pandas\_libs\index.pyx", line 147, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\index.pyx", line 176, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\_libs\hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 12 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 128, in <module> data = optimizing() File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 15, in __init__ self.optimizing_main() File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 124, in optimizing_main self.child2=self.mutation_cdata(fitness_data,self.cross_data) File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 92, in mutation_cdata print('cross_data[波束场景No]',bs_data[12]) File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 3761, in __getitem__ indexer = self.columns.get_loc(key) File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3654, in get_loc raise KeyError(key) from err KeyError: 12

Traceback (most recent call last): File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 3802, in get_loc return self._engine.get_loc(casted_key) File "pandas\_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\_libs\hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'A' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "e:\Mydata\py\提取指定范围excel数据.py", line 7, in <module> data = df.loc[0:9, 'A':'B'] # 例如提取第1行到第10行,第1列到第3列的数据 File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 1067, in __getitem__ return self._getitem_tuple(key) File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 1256, in _getitem_tuple return self._getitem_tuple_same_dim(tup) File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 924, in _getitem_tuple_same_dim retval = getattr(retval, self.name)._getitem_axis(key, axis=i) File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 1290, in _getitem_axis return self._get_slice_axis(key, axis=axis) File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 1324, in _get_slice_axis indexer = labels.slice_indexer(slice_obj.start, slice_obj.stop, slice_obj.step) File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 6559, in slice_indexer start_slice, end_slice = self.slice_locs(start, end, step=step) File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 6767, in slice_locs start_slice = self.get_slice_bound(start, "left") File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 6686, in get_slice_bound raise err File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 6680, in get_slice_bound slc = self.get_loc(label) File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 3804, in get_loc raise KeyError(key) from err KeyError: 'A'

最新推荐

recommend-type

[Oracle] dbms_metadata.get_ddl 的使用方法总结

如果需要获取一个模式下所有对象的DDL,可以编写脚本来遍历`DBA_TABLES`、`DBA_VIEWS`、`DBA_INDEXES`、`DBA_OBJECTS`等数据字典视图。例如,获取所有表的DDL: ```sql SET PAGESIZE 0 SET LONG 90000 SET FEEDBACK...
recommend-type

python1111111111

python1111111111
recommend-type

群山环绕的蓝色风景PPT模板下载

资源摘要信息:"重峦叠嶂的群山背景图片PPT模板" 知识点: 1. PPT模板的定义和应用:PPT模板是预先设计好的演示文稿样式,用于快速制作演示文稿或幻灯片。它通常包括背景设计、字体样式、配色方案和布局等元素。在进行演讲、汇报、教学或商业展示时,使用PPT模板可以提高制作效率,统一视觉效果,使内容更加吸引人。 2. 背景图片的作用:在PPT模板中,背景图片是至关重要的设计元素之一。它不仅能够为演示文稿设定基调和氛围,还可以增强信息传达的视觉效果,使观众更容易接受和理解演讲内容。好的背景图片应简洁而不抢眼,能够衬托主题,让内容成为焦点。 3. 山景图片的象征意义:山景图片通常给人以稳重、稳固和坚韧不拔的象征意义。在演示文稿中使用山景背景图片,可以传递出坚持不懈、勇攀高峰的主题和信息。重峦叠嶂的群山图片则能够突出这种寓意,适用于激励性演讲或团队合作主题的展示。 4. 文件格式与使用场景:本PPT模板文件以.jpg格式提供,它是一种常用的图像文件格式,用于网络传输、网页显示或个人计算机保存。由于.jpg文件具有压缩特性,因此适合用于网络下载或电子设备间共享,但需要注意的是,过多压缩可能会导致图像质量降低。 5. 免费资源的获取与注意事项:第一PPT模板网提供了精美风景幻灯片背景图片的免费下载,这为很多需要节省成本的用户提供了便利。然而,免费资源在使用时需要遵守相关网站的使用条款,可能包含版权声明或在商业用途上的限制。用户下载使用前应仔细阅读许可协议,避免侵犯版权或违规使用。 6. .ppt文件的编辑与制作:虽然本资源提供的是背景图片,但用户在获得图片后可能需要将其应用到.ppt演示文稿中。这通常需要使用Microsoft PowerPoint或其他类似软件(如WPS Office、Google Slides等)来完成。编辑时要注意保持背景图片与演示文稿内容的协调性,以及适当的图片尺寸和位置。 7. 压缩包子文件与资源管理:资源文件名称列表中包含了图片1.jpg以及其他文件,如使用帮助.txt、谷普下载.url、说明.url。这些文件可能是关于如何使用模板、下载链接或使用说明。用户在下载和使用这些资源时,应仔细检查文件清单,了解每个文件的作用,并正确管理这些资源,以避免丢失重要信息。 8. 知识产权保护:在使用任何设计素材时,无论是否免费,都应尊重知识产权。避免使用未经授权的素材,尤其是在商业项目中。使用时应确保素材来源的合法性和适用性,以免造成法律风险和道德争议。 通过以上知识点的介绍,用户可以更好地理解重峦叠嶂的群山背景图片PPT模板的价值和使用方法,并在设计演示文稿时更加得心应手。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【Python沉浸式音频体验】:虚拟现实中的音频处理技巧

![【Python沉浸式音频体验】:虚拟现实中的音频处理技巧](https://www.thetechinfinite.com/wp-content/uploads/2020/07/thetechinfinite-22-1024x576.jpg) # 1. 虚拟现实中的音频处理概述 虚拟现实技术已经不再是科幻小说中的概念,而是逐渐走入了我们的生活。在这个沉浸式的世界里,除了视觉效果外,音频处理也扮演了至关重要的角色。本章将为读者提供一个虚拟现实音频处理的概览,从基础理论到实际应用,从简单的音频增强到复杂的交互设计,我们将逐步深入探讨如何在虚拟环境中实现高质量的音频体验。 虚拟现实中的音频处
recommend-type

如何利用改进的LSTM模型进行智能车行为识别和轨迹预测,并通过加速度优化提升预测精度?

为了在智能车领域实现更为精确的行为识别和轨迹预测,改进的LSTM模型是一个有效的工具。结合《改进LSTM模型提升车辆轨迹预测精度:行为识别与优化策略》一文中的研究,以下步骤和细节将帮助你深入了解和应用这一技术: 参考资源链接:[改进LSTM模型提升车辆轨迹预测精度:行为识别与优化策略](https://wenku.csdn.net/doc/7k3q6biwdz?spm=1055.2569.3001.10343) 1. 数据预处理:首先,需要收集并预处理智能车的数据集,包括车辆的状态信息、行为信息以及与环境的交互信息。数据预处理包括标准化、去噪等步骤,为模型提供高质量的输入数据。 2. 改
recommend-type

dim-spa核心组件:JavaScript实现滚动条

资源摘要信息: "scroller: 滚动条" 在web开发中,滚动条是一个十分常见的界面元素,它是页面内容超出视窗时用于浏览更多内容的控制装置。开发者通常使用HTML、CSS和JavaScript等技术来控制滚动条的行为和样式。在本篇知识汇总中,我们将详细探讨JavaScript在创建和操作滚动条中的应用,同时结合相关技术细节,介绍如何在web页面中实现平滑滚动、动态内容加载和响应用户交互等功能。 ### JavaScript与滚动条 JavaScript是web开发中不可或缺的脚本语言,它允许开发者编写代码来动态地改变网页的外观和行为。在处理滚动条时,JavaScript可以提供精细的控制,例如监听滚动事件、获取滚动位置、改变滚动位置以及创建自定义滚动条等。 ### 监听滚动事件 为了响应滚动条的移动,开发者可以利用JavaScript中的`addEventListener`方法来监听滚动事件,如`scroll`事件。当用户滚动页面时,会触发该事件,并且可以执行与滚动相关的操作。 ```javascript document.addEventListener('scroll', function() { console.log('滚动位置:', window.scrollY); }); ``` ### 获取和设置滚动位置 通过JavaScript可以轻松获取或设置当前滚动位置。`window.scrollY`属性可以获取垂直滚动位置的像素值,而`window.scrollX`则用于获取水平滚动位置。开发者也可以使用`window.scrollTo(x, y)`或`element.scrollTo(options)`方法来编程式地改变滚动位置。 ```javascript // 获取当前垂直滚动位置 console.log(window.scrollY); // 设置滚动位置到页面顶部 window.scrollTo(0, 0); // 使用对象设置滚动位置 window.scrollTo({ top: 100, left: 100, behavior: 'smooth' }); ``` ### 动态内容加载与分页 在处理大量内容时,直接在页面上渲染所有数据可能会导致性能问题。此时,可以通过滚动条的位置来触发内容的懒加载(lazy loading)或分页加载(pagination)。这通常结合监听滚动事件和发送Ajax请求来实现。 ```javascript document.addEventListener('scroll', function() { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { // 到达页面底部时加载更多内容 loadMoreContent(); } }); function loadMoreContent() { // 发送Ajax请求获取新内容,并将其添加到页面中 } ``` ### 自定义滚动条样式 CSS提供了对滚动条样式的控制能力,但这种控制相对有限。通过使用JavaScript结合CSS,可以实现更加自定义的滚动条设计。虽然不推荐完全隐藏默认滚动条(因为它可能会影响用户体验),但在某些情况下,创建自定义滚动条确实可以提升视觉效果。 ```css /* 定义自定义滚动条的CSS样式 */ ::-webkit-scrollbar { width: 10px; } ::-webkit-scrollbar-track { background: #f1f1f1; } ::-webkit-scrollbar-thumb { background: #888; } ::-webkit-scrollbar-thumb:hover { background: #555; } ``` ### 与dim-spa结合 dim-spa(Dimensional Space)很可能是一个特定的框架或库,用于创建空间感知的web应用。在这个框架内,滚动条可能是一个用户界面组件,允许用户在一个多维空间中浏览内容。JavaScript可以在这个框架下提供更加动态和流畅的滚动体验。 ```javascript // 在dim-spa框架内控制滚动条 dimspa.scrollIntoView(element); ``` ### 结论 综合上述内容,JavaScript在滚动条的控制方面提供了非常强大的功能。无论是监听滚动事件、动态加载内容、还是创建自定义滚动条,JavaScript都能满足多样化的web开发需求。开发者应深入理解这些知识点,并在实际项目中灵活运用,以优化用户体验并提升界面交互的流畅度。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

Python虚拟现实网络编程:多人互动体验的设计与实现

![Python虚拟现实网络编程:多人互动体验的设计与实现](https://img-blog.csdnimg.cn/4eac4f0588334db2bfd8d056df8c263a.png) # 1. Python虚拟现实网络编程概述 在当今数字化时代,Python作为一门充满活力的编程语言,以其简洁明了的语法和强大的社区支持,在网络编程和虚拟现实(VR)应用开发领域中占据着重要的地位。Python的虚拟现实网络编程不仅结合了网络技术与VR的交互特性,还为开发者提供了一个高效、灵活的编程环境,使得实现多人互动体验变得更加可行。 ## 1.1 虚拟现实技术与网络编程的融合 虚拟现实技术通
recommend-type

在MATLAB中,如何快速查找sin函数的帮助文档,并演示如何设置不同的数据显示格式来输出sin函数的计算结果?

在MATLAB命令行中,你可以使用多种方法来查找特定函数的帮助文档,例如sin函数的帮助信息。最直接的方式是使用`help`命令,即在MATLAB命令窗口输入`help sin`,系统将返回sin函数的详细帮助信息,包括它的描述、语法和使用例证。如果你想要查找包含特定关键字的帮助文档,可以使用`lookfor`命令,例如`lookfor trigonometry`将会列出所有与三角函数相关的帮助文档。 参考资源链接:[MATLAB公式与常用命令指南](https://wenku.csdn.net/doc/8945be0k58?spm=1055.2569.3001.10343) 为了以不同的