07 2021 档案

pytorch中的梯度累加(Gradient Accumulation)
摘要:PyTorch中,在反向传播前为什么要手动将梯度清零? 原因在于,在PyTorch中,计算得到的梯度值会进行累加,而这样的好处,可以从内存消耗的角度来看。 在PyTorch中,multi-task任务一个标准的train from scratch流程为: for idx, data in enume 阅读全文

posted @ 2021-07-25 12:37 朴素贝叶斯 阅读(2844) 评论(1) 推荐(1) 编辑

88. 合并两个有序数组
摘要:题目描述 Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space to hold additional elem 阅读全文

posted @ 2021-07-24 17:17 朴素贝叶斯 阅读(41) 评论(0) 推荐(0) 编辑

138. 复制带随机指针的链表
摘要:题目描述 A linked list is given such that each node contains an additional random pointer which could point to any node in the list or nullptr. Return a d 阅读全文

posted @ 2021-07-24 15:51 朴素贝叶斯 阅读(27) 评论(0) 推荐(0) 编辑

27. 移除元素
摘要:题目描述 Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesnt 阅读全文

posted @ 2021-07-24 12:25 朴素贝叶斯 阅读(44) 评论(0) 推荐(0) 编辑

75. 颜色分类
摘要:题目描述 Given an array with n objects colored red(红), white(白) or blue(蓝),sort them so that objects of the same color are adjacent, with the colors in th 阅读全文

posted @ 2021-07-24 11:34 朴素贝叶斯 阅读(65) 评论(0) 推荐(0) 编辑

82. 删除排序链表中的重复元素 II
摘要:题目描述 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Give 阅读全文

posted @ 2021-07-24 09:40 朴素贝叶斯 阅读(54) 评论(0) 推荐(0) 编辑

83. 删除排序链表中的重复元素
摘要:题目描述 Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return1->2. Given 1->1->2- 阅读全文

posted @ 2021-07-24 08:35 朴素贝叶斯 阅读(27) 评论(0) 推荐(0) 编辑

80. 删除排序数组中的重复项 II
摘要:题目描述 Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A =[1,1,1,2,2,3],Your function shou 阅读全文

posted @ 2021-07-24 07:46 朴素贝叶斯 阅读(31) 评论(0) 推荐(0) 编辑

26. 删除排序数组中的重复项
摘要:题目描述 Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra spac 阅读全文

posted @ 2021-07-24 06:58 朴素贝叶斯 阅读(36) 评论(0) 推荐(0) 编辑

258. 各位相加
摘要:题目描述 给定一个非负整数 num,反复将各个位上的数字相加,直到结果为一位数。 示例: 输入: 38 输出: 2 解释: 各位相加的过程为:3 + 8 = 11, 1 + 1 = 2。 由于 2 是一位数,所以返回 2。 进阶: 你可以不使用循环或者递归,且在 O(1) 时间复杂度内解决这个问题吗 阅读全文

posted @ 2021-07-21 07:55 朴素贝叶斯 阅读(112) 评论(0) 推荐(0) 编辑

89. 格雷编码
摘要:题目描述 格雷编码是一个二进制数字系统,在该系统中,两个连续的数值仅有一个位数的差异。 给定一个代表编码总位数的非负整数 n,打印其格雷编码序列。格雷编码序列必须以 0 开头。 示例 1: 输入: 2 输出: [0,1,3,2] 解释: 00 - 0 01 - 1 11 - 3 10 - 2 对于给 阅读全文

posted @ 2021-07-21 06:45 朴素贝叶斯 阅读(100) 评论(0) 推荐(0) 编辑

20. 有效的括号
摘要:题目描述 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。左括号必须以正确的顺序闭合。注意空字符串可被认为是有效字符串。 示例 1: 输入: "()" 输出: true 示例 2: 输入: "()[ 阅读全文

posted @ 2021-07-20 23:35 朴素贝叶斯 阅读(38) 评论(0) 推荐(0) 编辑

32. 最长有效括号
摘要:题目描述 给定一个只包含 '(' 和 ')' 的字符串,找出最长的包含有效括号的子串的长度。 示例 1: 输入: "(()" 输出: 2 解释: 最长有效括号子串为 "()" 示例 2: 输入: ")()())" 输出: 4 解释: 最长有效括号子串为 "()()" #方法1 思路 用栈解决这个问题 阅读全文

posted @ 2021-07-20 21:10 朴素贝叶斯 阅读(41) 评论(0) 推荐(0) 编辑

67. 二进制求和
摘要:题目描述 Given two binary strings, return their sum (also a binary string). For example, a ="11" b ="1" Return "100". 代码实现 class Solution { public: string 阅读全文

posted @ 2021-07-20 20:13 朴素贝叶斯 阅读(30) 评论(0) 推荐(0) 编辑

7. Reverse Integer
摘要:#题目描述 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers(剧透).Have you thought about th 阅读全文

posted @ 2021-07-20 19:26 朴素贝叶斯 阅读(28) 评论(0) 推荐(0) 编辑

66. 加一
摘要:题目描述 Given a number represented as an array of digits, plus one to the number. 代码实现 class Solution { public: vector<int> plusOne(vector<int> &digits) 阅读全文

posted @ 2021-07-20 19:02 朴素贝叶斯 阅读(16) 评论(0) 推荐(0) 编辑

236. 二叉树的最近公共祖先
摘要:题目描述 给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。 百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的 深度尽可能大(一个节点也可以是它自己的祖先)。” 例如,给定如下二叉树: root = [ 阅读全文

posted @ 2021-07-19 23:59 朴素贝叶斯 阅读(72) 评论(0) 推荐(0) 编辑

235. 二叉搜索树的最近公共祖先
摘要:题目描述 给定一个二叉搜索树, 找到该树中两个指定节点的最近公共祖先。百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。” 例如,给定如下二叉搜索树: root = 阅读全文

posted @ 2021-07-19 23:15 朴素贝叶斯 阅读(57) 评论(0) 推荐(0) 编辑

342. 4的幂
摘要:题目描述 给定一个整数 (32 位有符号整数),请编写一个函数来判断它是否是 4 的幂次方。 示例 1: 输入: 16 输出: true 示例 2: 输入: 5 输出: false 进阶: 你能不使用循环或者递归来完成本题吗? 方法1 class Solution { public: bool is 阅读全文

posted @ 2021-07-19 22:06 朴素贝叶斯 阅读(41) 评论(0) 推荐(0) 编辑

326. 3的幂
摘要:题目描述 给定一个整数,写一个函数来判断它是否是 3 的幂次方。 示例 1: 输入: 27 输出: true 示例 2: 输入: 0 输出: false 示例 3: 输入: 9 输出: true 示例 4: 输入: 45 输出: false 进阶: 你能不使用循环或者递归来完成本题吗? 解法1 将n 阅读全文

posted @ 2021-07-19 21:42 朴素贝叶斯 阅读(57) 评论(0) 推荐(0) 编辑

231. 2的幂
摘要:题目描述 给定一个整数,编写一个函数来判断它是否是 2 的幂次方。 示例 1: 输入: 1 输出: true 解释: 20 = 1 示例 2: 输入: 16 输出: true 解释: 24 = 16 示例 3: 输入: 218 输出: false #思路 二进制数位上只有一位为1,其余的全部为0,n 阅读全文

posted @ 2021-07-19 20:51 朴素贝叶斯 阅读(44) 评论(0) 推荐(0) 编辑

191. 位1的个数
摘要:题目描述 编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 ‘1’ 的个数(也被称为汉明重量)。 示例 1: 输入:00000000000000000000000000001011 输出:3 解释:输入的二进制串 00000000000000000000000000001011 中 阅读全文

posted @ 2021-07-19 19:41 朴素贝叶斯 阅读(33) 评论(0) 推荐(0) 编辑

pandas rank()函数
摘要:#api DataFrame.rank(axis=0,method='average',numeric_only=None,na_option='keep',ascending=True, pct=False) Compute numerical data ranks (1 through n) a 阅读全文

posted @ 2021-07-18 17:00 朴素贝叶斯 阅读(184) 评论(0) 推荐(0) 编辑

65. 有效数字
摘要:题目描述 Validate(合法的) if a given string is numeric. Some examples: "0" ⇒ true " 0.1 " ⇒ true "abc" ⇒ false "1 a" ⇒ false "2e10" ⇒ true "." false "+e10" f 阅读全文

posted @ 2021-07-18 14:21 朴素贝叶斯 阅读(66) 评论(0) 推荐(0) 编辑

8. 字符串转换整数 (atoi)
摘要:题目描述 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see b 阅读全文

posted @ 2021-07-18 13:36 朴素贝叶斯 阅读(74) 评论(0) 推荐(0) 编辑

4. 寻找两个有序数组的中位数
摘要:题目描述 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 你可以假设 nums1 和 nums2 不会同时为空。 示例 1: nums1 = [1, 3] nums2 = [2] 则中位数是 阅读全文

posted @ 2021-07-18 12:50 朴素贝叶斯 阅读(53) 评论(0) 推荐(0) 编辑

229. 求众数 II
摘要:题目描述 给定一个大小为 n 的数组,找出其中所有出现超过 ⌊ n/3 ⌋ 次的元素。说明: 要求算法的时间复杂度为 O(n),空间复杂度为 O(1)。 示例 1: 输入: [3,2,3] 输出: [3] 示例 2: 输入: [1,1,1,3,3,2,2,2] 输出: [1,2] 提示1: How 阅读全文

posted @ 2021-07-18 12:11 朴素贝叶斯 阅读(54) 评论(0) 推荐(0) 编辑

169. 求众数
摘要:#题目描述 给定一个大小为n的数组,找到其中的众数。众数是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素。你可以假设数组是非空的,并且给定的数组总是存在众数。 示例 1: 输入: [3,2,3] 输出: 3 示例 2: 输入: [2,2,1,1,1,2,2] 输出: 2 思路 其实可以使用反证法来论 阅读全文

posted @ 2021-07-18 11:20 朴素贝叶斯 阅读(120) 评论(0) 推荐(0) 编辑

2. 两数相加
摘要:题目描述 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a si 阅读全文

posted @ 2021-07-17 23:51 朴素贝叶斯 阅读(31) 评论(0) 推荐(0) 编辑

torch.rand和torch.randn有什么区别
摘要:![image](https://img2020.cnblogs.com/blog/1852906/202107/1852906-20210705234209528-1434686312.png) ![image](https://img2020.cnblogs.com/blog/1852906/202107/1852906-20210705234219938-1681047286.png) 阅读全文

posted @ 2021-07-05 23:43 朴素贝叶斯 阅读(133) 评论(0) 推荐(0) 编辑

torch.nn.Softmax
摘要:![image](https://img2020.cnblogs.com/blog/1852906/202107/1852906-20210705233442023-561039642.png) ![image](https://img2020.cnblogs.com/blog/1852906/202107/1852906-20210705233453712-1182397838.png) 阅读全文

posted @ 2021-07-05 23:35 朴素贝叶斯 阅读(76) 评论(0) 推荐(0) 编辑

torch.sum()
摘要:![image](https://img2020.cnblogs.com/blog/1852906/202107/1852906-20210705205320898-272909016.png) ![image](https://img2020.cnblogs.com/blog/1852906/202107/1852906-20210705205336440-209994528.png) ![im 阅读全文

posted @ 2021-07-05 20:55 朴素贝叶斯 阅读(50) 评论(0) 推荐(0) 编辑

(译)BERT Fine-Tuning Tutorial with PyTorch
摘要:本文原地址见这里,与本教程对应的 Colab Notebook的地址在这里,里面包含了完整的可运行的代码。 Introduction History 2018 年是 NLP 突破的一年,迁移学习、特别是 Allen AI 的 ELMO,OpenAI 的 Open-GPT,以及 Google 的 BE 阅读全文

posted @ 2021-07-01 22:48 朴素贝叶斯 阅读(853) 评论(0) 推荐(0) 编辑

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

统计

点击右上角即可分享
微信分享提示