if self.gen is None: indexes = np.arange(len(self.image_names), dtype=np.int) if self._shuffle: np.random.shuffle(indexes) self.gen = self.pool.imap(partial(self._im_processor, size_index=None), ([self.image_names[i], self.get_annotation(i), self.dst_size] for i in indexes), chunksize=self.batch_size) self._epoch += 1 print(('epoch {} start...'.format(self._epoch)))

时间: 2024-02-10 20:28:27 浏览: 160
这段代码是一个条件语句,它检查实例变量 `gen` 是否为 `None`。如果 `gen` 是 `None`,则执行以下操作: 1. 创建一个整数数组 `indexes`,其长度与 `self.image_names` 相同,并使用 `np.arange()` 函数填充。 2. 如果 `_shuffle` 为 `True`,则使用 `np.random.shuffle()` 函数对 `indexes` 进行随机洗牌。 3. 使用 `self.pool.imap()` 方法创建一个迭代器 `gen`,将其赋值给实例变量 `self.gen`。该迭代器使用部分函数 `_im_processor` 处理传入的参数,并使用 `([self.image_names[i], self.get_annotation(i), self.dst_size] for i in indexes)` 作为输入数据。`chunksize=self.batch_size` 指定每个进程块的大小。 4. 将实例变量 `_epoch` 的值增加 1。 5. 打印输出字符串 `'epoch {} start...'`,其中 `{}` 会被 `_epoch` 的值替换。 总之,这段代码的目的是在 `gen` 为空时,进行一些初始化操作,并将处理后的数据存储在 `gen` 中。同时,还会增加 `_epoch` 的值并打印相关信息,表示新的 epoch 开始了。
相关问题

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包

好的,将使用最新版的scipy包进行修改。首先需要将代码中的`is_pydata_spmatrix`替换为`isspmatrix_csr`。同时需要将代码开头的导入语句修改为`from scipy.sparse.linalg import eigsh, LinearOperator from scipy.sparse import isspmatrix_csr`。

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

将代码修改为使用LM和迭代器使用arpack的方法如下: ```python 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) 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 dtype = A.dtype 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=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, mode=self.solver) # 格拉米矩阵有实非负特征值。 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': u = _augmented_orthonormal_cols(ularge, nsmall) if ularge is not None else None else: u = None if self.return_singular_vectors != 'vh': vh = _augmented_orthonormal_rows(vhlarge, nsmall) if vhlarge is not None else None else: vh = 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[index_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) ```
阅读全文

相关推荐

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查看,有报错,可能是缩进有问题,无法被调用,根据这个问题,给出解决办法,给出改正后的完整代码

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的数量,请用代码表示

详细解释一下这段代码GTV_indexes = [] GTVs_sum = np.zeros((512,512)) # Find the cuts containning GTV contours minXY = 600 maxXY = -1 for time in times: path = folder+patient+'\\'+str(int(time)) # Find the filenames starting with CT minXY1,maxXY1,GTV_index = findContours(path,isPlot=False) GTV_indexes=np.append(GTV_indexes,GTV_index) if minXY>minXY1: minXY = minXY1 elif maxXY<maxXY1: maxXY = maxXY1 print('minXY={}'.format(minXY),'maxXY={}'.format(maxXY)) GTV_indexes = np.array(GTV_indexes) GTV_indexes = np.unique(GTV_indexes).astype(int) print('Cuts including GTVs: {}'.format(GTV_indexes)) writeToFile(GTV_indexes,folder+patient+'\\GTV_indexs.txt') #将DICOM文件的拍摄时间与呼吸曲线对应 #CT scanning time # 由vxp文件获取开始扫描的时刻 vxpPath = folder+patient+'\\0006863819_20200730_090003.vxp' injectTime = getInjectionTime(vxpPath) print('Initial injection time of CT from vxp file:{}'.format(injectTime)) # 得到GTV cut的扫描时刻 scanTimes = np.ones((len(times),len(cuts))) print('scan time of each phase CT') for i,time in enumerate(times,start=0): for j,cut in enumerate(cuts,start=0): filename = folder+patient+'\\'+str(int(time))+'\\CT.{}'.format(patient)+'.Image {}.dcm'.format(int(cut)) scanTime = getScanTime(filename) scanTimes[i,j] = scanTime scanTimes = scanTimes-scanTimes.min()+injectTime # 画出呼吸曲线,并得到相应的呼吸幅度 amplitudes = getBreathingCurve(vxpPath,scanTimes,isplot=1) writeToFile(scanTimes,folder+patient+'\\scanTimes.txt') writeToFile(amplitudes,folder+patient+'\\amplitudes.txt')

KeyError Traceback (most recent call last) Cell In[17], line 1 ----> 1 data = data.drop(['125','125.1'],axis=1) 2 data File D:\anaconda\envs\zuoye\lib\site-packages\pandas\core\frame.py:5268, in DataFrame.drop(self, labels, axis, index, columns, level, inplace, errors) 5120 def drop( 5121 self, 5122 labels: IndexLabel = None, (...) 5129 errors: IgnoreRaise = "raise", 5130 ) -> DataFrame | None: 5131 """ 5132 Drop specified labels from rows or columns. 5133 (...) 5266 weight 1.0 0.8 5267 """ -> 5268 return super().drop( 5269 labels=labels, 5270 axis=axis, 5271 index=index, 5272 columns=columns, 5273 level=level, 5274 inplace=inplace, 5275 errors=errors, 5276 ) File D:\anaconda\envs\zuoye\lib\site-packages\pandas\core\generic.py:4549, in NDFrame.drop(self, labels, axis, index, columns, level, inplace, errors) 4547 for axis, labels in axes.items(): 4548 if labels is not None: -> 4549 obj = obj._drop_axis(labels, axis, level=level, errors=errors) 4551 if inplace: 4552 self._update_inplace(obj) File D:\anaconda\envs\zuoye\lib\site-packages\pandas\core\generic.py:4591, in NDFrame._drop_axis(self, labels, axis, level, errors, only_slice) 4589 new_axis = axis.drop(labels, level=level, errors=errors) 4590 else: -> 4591 new_axis = axis.drop(labels, errors=errors) 4592 indexer = axis.get_indexer(new_axis) 4594 # Case for non-unique axis 4595 else: File D:\anaconda\envs\zuoye\lib\site-packages\pandas\core\indexes\base.py:6696, in Index.drop(self, labels, errors) 6694 if mask.any(): 6695 if errors != "ignore": -> 6696 raise KeyError(f"{list(labels[mask])} not found in axis") 6697 indexer = indexer[~mask] 6698 return self.delete(indexer) KeyError: "['125', '125.1'] not found in axis"

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

import matplotlib as mpl import matplotlib.pyplot as plt plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=0.5) t=np.arange(0.0,2.0,0.1) s=np.sin(t*np.pi) plt.subplot(2,2,1) #要生成两行两列,这是第一个图 import numpy as np import matplotlib.pyplot as plt x = np.arange(1,13) y1 = np.array([53673, 57571, 58905, 55239, 49661, 49510, 49163, 57311, 59187, 60074, 57109, 52885]) plt.plot(x, y1) plt.title('近13天登录人数') plt.show() plt.subplot(2,2,2) #两行两列,这是第二个图 import numpy as np import matplotlib.pyplot as plt plt.subplots_adjust(top=0.85) x = np.arange(12) y = np.array([70887, 64957, 62508, 66471, 54972, 46245, 64083, 67090, 64991, 88504, 79404, 68253,]) bar_width = 0.3 plt.bar(x, y, tick_label=['1月', '2月', '3月', '4月', '5月', '6月', '7月', "8月", "9月", "10月", '11月', '12月'],width=bar_width) plt.title('近12个月人数') plt.show() plt.subplot(2,2,3)#两行两列,这是第三个图 import matplotlib.pyplot as plt plt.subplots_adjust(top=0.85) plt.style.use('fivethirtyeight') languages = ['steam', 'ubisoft'] popularity = [78,22] plt.pie(popularity) plt.tight_layout() plt.pie(popularity, labels=languages, autopct='%1.1f%%') plt.title('游戏平台登录占比') plt.subplot(2,2,4)#两行两列,这是第四个图 import numpy as np from matplotlib import pyplot as plt ages_x = [1, 2, 3, 4, 5, ] x_indexes = np.arange(len(ages_x)) width = 0.33 dev_y = [64050, 65168, 75588, 75590, 60097] py_dev_y = [57809, 56101, 70605, 63437, 56756] plt.bar(x_indexes, dev_y, width=width, label="2022") plt.bar(x_indexes + width, py_dev_y, width=width, label="2023") plt.xlabel("月份") plt.ylabel("平均在线人数") plt.title("2022和2023一到五月在线人数对比") plt.legend() plt.xticks(ticks = x_indexes, labels = ages_x) plt.show()

最新推荐

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

前端面试攻略(前端面试题、react、vue、webpack、git等工具使用方法)

javascript 前端面试攻略(前端面试题、react、vue、webpack、git等工具使用方法)
recommend-type

常用的java基础类包括MD5、错误处理、映射、服务等等

MD5、错误处理、映射、服务等等 BaseController.java BaseQuery.java ResultInfo.java BaseMapper.java BaseService.java AssertUtil.java LoginUserUtil.java PhoneUtil.java CookieUtil.java Md5Util.java UserIDBase64.java NoLoginException.java ParamsException.java
recommend-type

带头像公司组织机构图PPT模板-2.pptx

图表分类ppt
recommend-type

租赁合同编写指南及下载资源

资源摘要信息:《租赁合同》是用于明确出租方与承租方之间的权利和义务关系的法律文件。在实际操作中,一份详尽的租赁合同对于保障交易双方的权益至关重要。租赁合同应当包括但不限于以下要点: 1. 双方基本信息:租赁合同中应明确出租方(房东)和承租方(租客)的名称、地址、联系方式等基本信息。这对于日后可能出现的联系、通知或法律诉讼具有重要意义。 2. 房屋信息:合同中需要详细说明所租赁的房屋的具体信息,包括房屋的位置、面积、结构、用途、设备和家具清单等。这些信息有助于双方对租赁物有清晰的认识。 3. 租赁期限:合同应明确租赁开始和结束的日期,以及租期的长短。租赁期限的约定关系到租金的支付和合同的终止条件。 4. 租金和押金:租金条款应包括租金金额、支付周期、支付方式及押金的数额。同时,应明确规定逾期支付租金的处理方式,以及押金的退还条件和时间。 5. 维修与保养:在租赁期间,房屋的维护和保养责任应明确划分。通常情况下,房东负责房屋的结构和主要设施维修,而租客需负责日常维护及保持房屋的清洁。 6. 使用与限制:合同应规定承租方可以如何使用房屋以及可能的限制。例如,禁止非法用途、允许或禁止宠物、是否可以转租等。 7. 终止与续租:租赁合同应包括租赁关系的解除条件,如提前通知时间、违约责任等。同时,双方可以在合同中约定是否可以续租,以及续租的条件。 8. 解决争议的条款:合同中应明确解决可能出现的争议的途径,包括适用法律、管辖法院等,有助于日后纠纷的快速解决。 9. 其他可能需要的条款:根据具体情况,合同中可能还需要包括关于房屋保险、税费承担、合同变更等内容。 下载资源链接:【下载自www.glzy8.com管理资源吧】Rental contract.DOC 该资源为一份租赁合同模板,对需要进行房屋租赁的个人或机构提供了参考价值。通过对合同条款的详细列举和解释,该文档有助于用户了解和制定自己的租赁合同,从而在房屋租赁交易中更好地保护自己的权益。感兴趣的用户可以通过提供的链接下载文档以获得更深入的了解和实际操作指导。
recommend-type

【项目管理精英必备】:信息系统项目管理师教程习题深度解析(第四版官方教材全面攻略)

![信息系统项目管理师教程-第四版官方教材课后习题-word可编辑版](http://www.bjhengjia.net/fabu/ewebeditor/uploadfile/20201116152423446.png) # 摘要 信息系统项目管理是确保项目成功交付的关键活动,涉及一系列管理过程和知识领域。本文深入探讨了信息系统项目管理的各个方面,包括项目管理过程组、知识领域、实践案例、管理工具与技术,以及沟通和团队协作。通过分析不同的项目管理方法论(如瀑布、迭代、敏捷和混合模型),并结合具体案例,文章阐述了项目管理的最佳实践和策略。此外,本文还涵盖了项目管理中的沟通管理、团队协作的重要性,
recommend-type

最具代表性的改进过的UNet有哪些?

UNet是一种广泛用于图像分割任务的卷积神经网络结构,它的特点是结合了下采样(编码器部分)和上采样(解码器部分),能够保留细节并生成精确的边界。为了提高性能和适应特定领域的需求,研究者们对原始UNet做了许多改进,以下是几个最具代表性的变种: 1. **DeepLab**系列:由Google开发,通过引入空洞卷积(Atrous Convolution)、全局平均池化(Global Average Pooling)等技术,显著提升了分辨率并保持了特征的多样性。 2. **SegNet**:采用反向传播的方式生成全尺寸的预测图,通过上下采样过程实现了高效的像素级定位。 3. **U-Net+
recommend-type

惠普P1020Plus驱动下载:办公打印新选择

资源摘要信息: "最新惠普P1020Plus官方驱动" 1. 惠普 LaserJet P1020 Plus 激光打印机概述: 惠普 LaserJet P1020 Plus 是惠普公司针对家庭、个人办公以及小型办公室(SOHO)市场推出的一款激光打印机。这款打印机的设计注重小巧体积和便携操作,适合空间有限的工作环境。其紧凑的设计和高效率的打印性能使其成为小型企业或个人用户的理想选择。 2. 技术特点与性能: - 预热技术:惠普 LaserJet P1020 Plus 使用了0秒预热技术,能够极大减少打印第一张页面所需的等待时间,首页输出时间不到10秒。 - 打印速度:该打印机的打印速度为每分钟14页,适合处理中等规模的打印任务。 - 月打印负荷:月打印负荷高达5000页,保证了在高打印需求下依然能稳定工作。 - 标配硒鼓:标配的2000页打印硒鼓能够为用户提供较长的使用周期,减少了更换耗材的频率,节约了长期使用成本。 3. 系统兼容性: 驱动程序支持的操作系统包括 Windows Vista 64位版本。用户在使用前需要确保自己的操作系统版本与驱动程序兼容,以保证打印机的正常工作。 4. 市场表现: 惠普 LaserJet P1020 Plus 在上市之初便获得了市场的广泛认可,创下了百万销量的辉煌成绩,这在一定程度上证明了其可靠性和用户对其性能的满意。 5. 驱动程序文件信息: 压缩包内包含了适用于该打印机的官方驱动程序文件 "lj1018_1020_1022-HB-pnp-win64-sc.exe"。该文件是安装打印机驱动的执行程序,用户需要下载并运行该程序来安装驱动。 另一个文件 "jb51.net.txt" 从命名上来看可能是一个文本文件,通常这类文件包含了关于驱动程序的安装说明、版本信息或是版权信息等。由于具体内容未提供,无法确定确切的信息。 6. 使用场景: 由于惠普 LaserJet P1020 Plus 的打印速度和负荷能力,它适合那些需要快速、频繁打印文档的用户,例如行政助理、会计或小型法律事务所。它的紧凑设计也使得这款打印机非常适合在桌面上使用,从而不占用过多的办公空间。 7. 后续支持与维护: 用户在购买后可以通过惠普官方网站获取最新的打印机驱动更新以及技术支持。在安装新驱动之前,建议用户先卸载旧的驱动程序,以避免版本冲突或不必要的错误。 8. 其它注意事项: - 用户在使用打印机时应注意按照官方提供的维护说明定期进行清洁和保养,以确保打印质量和打印机的使用寿命。 - 如果在打印过程中遇到任何问题,应先检查打印机设置、驱动程序是否正确安装以及是否有足够的打印纸张和墨粉。 综上所述,惠普 LaserJet P1020 Plus 是一款性能可靠、易于使用的激光打印机,特别适合小型企业或个人用户。正确的安装和维护可以确保其稳定和高效的打印能力,满足日常办公需求。
recommend-type

数字电路实验技巧:10大策略,让你的实验效率倍增!

![数字电路实验技巧:10大策略,让你的实验效率倍增!](https://avatars.dzeninfra.ru/get-zen_doc/3964212/pub_5f76d5f2109e8f703cdee289_5f76f3c10d5f8951c997167a/scale_1200) # 摘要 本论文详细介绍了数字电路实验的基础理论、设备使用、设计原则、实践操作、调试与故障排除以及报告撰写与成果展示。首先探讨了数字电路实验所需的基本理论和实验设备的种类与使用技巧,包括测量和故障诊断方法。接着,深入分析了电路设计的原则,涵盖设计流程、逻辑简化、优化策略及实验方案的制定。在实践操作章节中,具体
recommend-type

altium designer布线

### Altium Designer 布线教程和技巧 #### 一、环境设置与准备 为了更高效地完成布线工作,前期的准备工作至关重要。确保原理图已经完全无误并编译成功[^2]。 #### 二、同步查看原理图与PCB布局 通过在原理图标题栏处右键点击并选择 "Split Vertical" 可实现原理图和PCB视图的同时展示,这有助于理解电路连接关系以及提高布线效率。 #### 三、自动布线器配置 Altium Designer内置有强大的自动布线功能。进入“Tools -> PCB Rules and Constraints Editor”,可以自定义诸如最小间距、过孔尺寸等参数来满足