# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def __init__(self):
self.res = []
def BSTSequences(self, root: TreeNode) -> list[list[int]]:
if not root:
return [[]]
self.dfs(root, [], [root.val])
return self.res
def dfs(self, root, q, path):
# todo 这里可以类比多少种 BFS树等
if not root:
return
if root.left:
q.append(root.left)
if root.right:
q.append(root.right)
if not q:
self.res.append(path)
for i, nex in enumerate(q):
new_path = q[:i] + q[i + 1:]
self.dfs(nex, new_path, path + [nex.val])
Review
How to build your own Neural Network from scratch in Python
概述
What’s a Neural Network?
Most introductory texts to Neural Networks brings up brain analogies when describing them. Without delving into brain
analogies, I find it easier to simply describe Neural Networks as a mathematical function that maps a given input to a
desired output.
Neural Networks consist of the following components
An input layer, x
An arbitrary amount of hidden layers
An output layer, ŷ
A set of weights and biases between each layer, W and b
A choice of activation function for each hidden layer, σ. In this tutorial, we’ll use a Sigmoid activation function.