自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(97)
  • 收藏
  • 关注

转载 搞懂推荐系统中的评价指标NDCG(CG、DCG、IDCG)

https://www.cnblogs.com/datasnail/p/13088964.html

2021-07-08 15:00:27 1462

转载 自监督学习

http://www.360doc.com/content/21/0508/12/7673502_976159452.shtml

2021-07-08 11:32:30 132

原创 关于collate_fn:

分为disabled(dataloader的batch_size和batch_sampler参数都为None)和enabled两种状态,当为disabled时,简单的把数据转为tensor;当为enabled时,将dataset中__getitem()__返回的数据打包成batch,并维持原有的数据结构(It preserves the data structure, e.g., if each sample is a dictionary, it outputs a dictionary with t..

2021-07-06 22:23:31 394

转载 pandas入门介绍

https://www.pypandas.cn/docs/getting_started/

2021-07-01 10:23:28 76

转载 Pycharm远程连接服务器端项目进行本地开发调试

https://cloud.tencent.com/developer/article/1675934

2021-07-01 10:09:43 103

转载 python中函数嵌套、函数作为变量以及闭包的原理

https://www.cnblogs.com/xiaxiaoxu/p/9785687.html

2021-06-30 16:41:23 93

转载 pytorch中的embedding词向量的使用方法

Embedding词嵌入在 pytorch 中非常简单,只需要调用 torch.nn.Embedding(m, n) 就可以了,m 表示单词的总数目,n 表示词嵌入的维度,其实词嵌入就相当于是一个大矩阵,矩阵的每一行表示一个单词。emdedding初始化默认是随机初始化的import torchfrom torch import nnfrom torch.autograd import Variable# 定义词嵌入embeds = nn.Embedding(2, 5) # 2 个

2021-06-25 10:20:08 802

转载 pytorch中的nn.CrossEntropyLoss()

nn.CrossEntropyLoss()这个损失函数和我们普通说的交叉熵还是有些区别。xx是模型生成的结果,classclass是数据对应的labelnn.CrossEntropyLoss()的使用方式参见如下代码import torchimport torch.nn as nn# 表示模型的输出output(B,C)格式,B是batch,C是类别output = torch.randn(2, 3, requires_grad = True) #batch_size设置为..

2021-06-21 17:18:20 668

原创 gitlab 解决502问题

在配置文件/ect/gitlab/gitlab.rv中写如下语句:external_url 'IP:PORT'一般安装成功gitlab后,该文件会自动生成这条配置,IP和端口号是自己的服务器IP和端口号,这个地方一定要注意端口号不能有冲突,冲突的话就会出现无法访问的问题。一定要检查端口有没有被使用设置好这条语句后如果还是出现502问题,那就是添加如下两条语句,缺一不可:u...

2019-07-12 09:11:20 2340

原创 Merge k Sorted Lists leetcode

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

2014-09-22 21:54:29 462

原创 堆排序

利用最大堆实现。最大堆:最大堆性质是除了根结点意外的所有结点 i 都要满足A[parent[i]] >= A[i]需要利用到的一个性质:当用数组表示存储n个元素的堆时,叶结点的下标分别是n/2, n/2+1, n/2 + 2, ......,n - 1.  (下标从0开始)需要用到的函数有:void max_heapify(int *a, int i)    //通

2014-09-22 20:10:59 381

原创 压栈思想计算运算表达式

栈的规则是先进后出。利用压栈的思想来计算四则运算表达式是这样的:我们给定两个栈,一个用来存放数字、一个用来存放对应的操作符。假定我们有一个给定的四则运算表达式a+b+c/d*(e+f)-d*a,那我们先把这个表达式拆分成一个个的数字或者是运算符、或者就是括号了。然后我们从左至右遍历每一个元素,遍历过程中遵循步骤和原则如下:       (1)遇到数字则直接压到数字栈顶。       (2)

2014-09-22 19:12:12 1026

原创 求最长单调递减子序列

解法一: 首先将这个序列进行排序,然后再求出已排序的和未排序的这两个数列最长公共子序列解法二:就是用动态规划法来解决问题

2014-09-22 16:52:20 549

原创 最长公共子串和最长公共子序列

注意最长公共子串(Longest CommonSubstring)和最长公共子序列(LongestCommon Subsequence, LCS)的区别:子串(Substring)是串的一个连续的部分,子序列(Subsequence)则是从不改变序列的顺序,而从序列中去掉任意的元素而获得的新序列;更简略地说,前者(子串)的字符的位置必须连续,后者(子序列LCS)则不必。比如字符串acdfg同akd

2014-09-21 21:38:39 570

原创 Implement strStr() leetcode

Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.

2014-09-17 23:56:04 320

原创 Rotate List leetcode

Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.

2014-09-17 19:59:41 340

原创 Permutation Sequence leetcode

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""3

2014-09-12 10:51:44 366

原创 Sqrt(x) leetcode

Implement int sqrt(int x).Compute and return the square root of x.

2014-09-11 16:33:46 372

原创 Longest Substring Without Repeating Characters leetcode

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

2014-09-11 16:13:08 362

原创 Best Time to Buy and Sell Stock III leetcode

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You ma

2014-09-11 15:24:45 394

原创 First Missing Positive leetcode

Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant

2014-09-10 20:16:27 360

原创 Scramble String leetcode

https://oj.leetcode.com/problems/scramble-string/

2014-09-10 19:39:54 623

原创 vector的reserve和resize

vector 的reserve增加了vector的capacity,但是它的size没有改变!而resize改变了vector的capacity同时也增加了它的size!原因如下:      reserve是容器预留空间,但在空间内不真正创建元素对象,所以在没有添加新的对象之前,不能引用容器内的元素。加入新的元素时,要调用push_back()/insert()函数。      r

2014-09-10 17:15:13 380

原创 Clone Graph leetcode

Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.

2014-09-10 16:40:15 358

原创 ZigZag Conversion leetcode

he string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I

2014-09-09 12:31:16 366

原创 Word Break leetcode

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"

2014-09-03 09:00:24 376

原创 Reorder List leetcode

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to 

2014-09-02 19:31:00 425

原创 LRU Cache leetcode

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if

2014-09-02 17:06:20 347

原创 Sort List leetcode

Sort a linked list in O(n log n) time using constant space complexity.

2014-09-02 14:16:45 290

原创 Reverse Nodes in k-Group leetcode

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is

2014-09-01 22:01:16 367

原创 Distinct Subsequences leetcode

Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non

2014-09-01 20:11:14 287

原创 怎样用指定的随机数生成函数来实现新的随机数生成函数

阿里巴巴笔试题:假设函数rand_k会随机返回一个【1,k】之间的随机数(k>=2),并且每个整数出现的概率相等。目前有 rand_7,通过调用rand_7()和四则运算符,并适当增加逻辑判断和循环控制逻辑,下列函数可以实现的有:ABCDA:rand_5 B:rand_21 C:rand_23 D:rand_49解析:先考虑如何用rand_7()实现rand_5():

2014-08-27 23:29:11 643

原创 Edit Distance leetcode

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2014-08-27 20:50:45 430

原创 Gas Station leetcode

There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to

2014-08-27 08:48:17 412

原创 Palindrome Partitioning I and II leetcode

Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","

2014-08-26 19:38:15 352

原创 Combination Sum leetcode

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb

2014-08-22 19:15:15 377

原创 Triangle leetcode

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [

2014-08-21 20:15:07 357

原创 3Sum leetcode

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c

2014-08-21 09:49:22 386

原创 Two Sum leetcode

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2014-08-21 08:21:12 342

原创 C++堆,栈,静态存储区介绍

1、栈区(stack)— 由编译器自动分配释放 ,存放函数参数值,局部变量值等。其操作方式类似于数据结构中栈。2、堆区(heap) — 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收 。注意它与数据结构中堆是两回事,分配方式倒是类似于链表,呵呵。3、全局区(静态区)(static)—,全局变量和静态变量存储是放在一块,初始化全局变量和静态变量在一块区域, 未初

2014-08-20 16:23:39 478

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除