11 2019 档案
摘要:先随便设置的参数: 没想到它居然有效果: 这弯弯扭扭的准确率曲线看上去势头还不错。准确率百分之40.5%。 将epoch由500设置为5000看看: 是不是不池化更好一点。。。 把池化层去掉,epoch设置为6000: loss下降了一点点,accuracy下降了一点,,但是要是提前停止训练,应该会
阅读全文
摘要:输出层没有添加激活函数softmax 虽然loss的值不高,但是accuracy的值也很低,虽然训练集的loss一致在下降,但是测试集的loss却在震荡,几乎不变。不知道该怎么解决。——2019.11.28 11:29 输出层添加了softmax激活函数之后: 为什么验证集的Loss降到一半就再不降
阅读全文
摘要:似懂非懂。。 class Solution: def diameterOfBinaryTree(self, root: TreeNode) -> int: self.ans=1 def depth(node): if not node: return 0 L=depth(node.left) R=d
阅读全文
摘要:不是自己写的。。 class Solution: def smallestFromLeaf(self, root: TreeNode) -> str: self.ans="~" def dfs(node,A): if node: A.append(chr(node.val+ord('a'))) if
阅读全文
摘要:很简单,,但是自己还是没写出来。。。。 class Solution: def sumNumbers(self, root: TreeNode) -> int: self.res=0 def helper(root,tmp): if not root:return if not root.left
阅读全文
摘要:自己还是没做出来。。 class Solution: def binaryTreePaths(self, root: TreeNode) -> List[str]: if not root: return [] res=[] def helper(root,temp): if not root.le
阅读全文
摘要:同看懂做不出来。。。 class Solution: def pathSum(self, root: TreeNode, sum: int) -> List[List[int]]: res=[] if not root: return [] def helper(root,sum,tmp): if
阅读全文
摘要:class Solution: def pathSum(self, root: TreeNode, sum: int) -> int: if not root: return 0 def dfs(node,sums): left=right=0 temp=[num+node.val for num
阅读全文
摘要:class Solution: def longestUnivaluePath(self, root: TreeNode) -> int: self.ans=0 def arrow_length(node): if not node: return 0 left_length=arrow_lengt
阅读全文
摘要:class Solution: def isUnivalTree(self, root: TreeNode) -> bool: if not root: return True else: a=root.val if root.left and root.left.val!=a: return Fa
阅读全文
摘要:class Solution: def sumOfLeftLeaves(self, root: TreeNode) -> int: if not root: return 0 if root and root.left and not root.left.left and not root.left
阅读全文
摘要:并没有理解这种递归想法: class Solution: def __init__(self): self.ans=None def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'Tree
阅读全文
摘要:class Solution: def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': if p.val>q.val: p,q=q,p if q.val<root.va
阅读全文
摘要:暴力法: class Solution: def countNodes(self, root: TreeNode) -> int: if not root: return 0 else: return 1+self.countNodes(root.left)+self.countNodes(root
阅读全文
摘要:class Solution: def invertTree(self, root: TreeNode) -> TreeNode: if not root: return root def helper(node): if node: if node.left or node.right: node
阅读全文
摘要:class Solution: def hasPathSum(self, root: TreeNode, sum: int) -> bool: if not root: return False if not root.left and not root.right and sum - root.v
阅读全文
摘要:好开心,我终于独立完成了!!!! class Solution: def sortedArrayToBST(self, nums: List[int]) -> TreeNode: if len(nums)==0: return None i=len(nums)//2 root=TreeNode(nu
阅读全文
摘要:class Solution: def isBalanced(self, root: TreeNode) -> bool: if not root: return True def helper(node): if not node: return 0 left=helper(node.left)
阅读全文
摘要:同111题 class Solution(object): def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ if not root: return 0 left = self.maxDepth(root.left)
阅读全文
摘要:0.。。。。 class Solution(object): def minDepth(self, root): """ :type root: TreeNode :rtype: int """ if not root: return 0 left = self.minDepth(root.left
阅读全文
摘要:不是自己想出来的,什么时候才能独立完成树的题。 class Solution(object): def levelOrder(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ levels=[] if not root
阅读全文
摘要:0 class Solution: def numTrees(self, n: int) -> int: dp = [0] * (n + 1) dp[0] = 1 dp[1] = 1 for i in range(2, n + 1): for j in range(i): dp[i] += dp[j
阅读全文
摘要:不是我自己做出来的 class Solution(object): def generateTrees(self,n): Listn = [i for i in range(1, n+1)] def gt(List): res = [] if not List: return [None] if l
阅读全文
摘要:搭建一个简易网络模型: import tensorflow as tf model=tf.keras.Sequential() model.add(tf.keras.layers.Dense(64,input_shape=(20,),activation='relu')) model.add(tf.
阅读全文
摘要:class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not root:return True def Tree(p,q): if not p and not
阅读全文
摘要:超出时间了。。。 class Solution(object): def countRangeSum(self, nums, lower, upper): """ :type nums: List[int] :type lower: int :type upper: int :rtype: int
阅读全文
摘要:也不是我做出来的,, class Solution(object): def isValidBST(self, root): """ :type root: TreeNode :rtype: bool """ res=[] def helper(root): if not root: return
阅读全文
摘要:这不是我写的,对于树的学习处于初始阶段。 class Solution(object): def inorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] """ white,gray=0,1 res=[] st
阅读全文
摘要:class Solution(object): def removeKdigits(self, num, k): """ :type num: str :type k: int :rtype: str """ if k>=len(num): return '0' i=0 j=1 while k an
阅读全文
摘要:这道题也不是我自己做出来的,只能说大佬牛逼!!! class Solution(object): def decodeString(self, s): """ :type s: str :rtype: str """ stack, res, multi = [], "", 0 for c in s:
阅读全文
摘要:这道题也不是我自己想出来的。。。 执行用时 :32 ms, 在所有 python 提交中击败了62.20%的用户 内存消耗 :11.7 MB, 在所有 python 提交中击败了44.44%的用户 ——2019.11.4
阅读全文
摘要:这个也不是我自己做出来的,感觉我还打不到这个水平,我好菜! class Solution: def maximalRectangle(self, matrix) -> int: if not matrix or not matrix[0]: return 0 row = len(matrix) co
阅读全文
摘要:class Solution(object): def largestRectangleArea(self, heights): """ :type heights: List[int] :rtype: int """ stack = [] heights = [0] + heights + [0]
阅读全文
摘要:执行用时 :132 ms, 在所有 python 提交中击败了81.56%的用户 内存消耗 :12.2 MB, 在所有 python 提交中击败了37.93%的用户 ——2019.11.2
阅读全文
摘要:执行用时 :16 ms, 在所有 python 提交中击败了93.78%的用户 内存消耗 :11.8 MB, 在所有 python 提交中击败了19.05%的用户 ——2019.11.2
阅读全文
摘要:执行用时 :248 ms, 在所有 python 提交中击败了58.82%的用户 内存消耗 :13.6 MB, 在所有 python 提交中击败了34.65%的用户 ——2019.11.2
阅读全文
摘要:执行用时 :76 ms, 在所有 python 提交中击败了36.29%的用户 内存消耗 :11.8 MB, 在所有 python 提交中击败了38.18%的用户 ——2019.11.2
阅读全文
摘要:执行用时 :660 ms, 在所有 python 提交中击败了24.93%的用户 内存消耗 :15.5 MB, 在所有 python 提交中击败了19.17%的用户 ——2019.11.2
阅读全文
摘要:执行用时 :60 ms, 在所有 python 提交中击败了92.56%的用户 内存消耗 :13.7 MB, 在所有 python 提交中击败了6.25%的用户 ——2019.11.2
阅读全文
摘要:class Solution(object): def simplifyPath(self, path): """ :type path: str :rtype: str """ stack=[] path=path.split('/') for item in path: if item=='..
阅读全文
摘要:# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def
阅读全文