def reverseBetween(self, head, m, n): """ :param head: ListNode :param m: int :param n: int :return: ListNode """ dummyhead = Node() dummyhead.next = head cur = head index = 1 pre = dummyhead while index <= n: if index >= m: """todo""" if index == m: m_node = cur m_pre = pre if index == n: n_node = cur n_next = cur.next next = cur.next cur.next = pre pre = cur cur = next index += 1 else: pre = cur cur = cur.next index += 1 m_pre.next = n_node m_node.next = n_next return dummyhead
def __init__(self, y, y_hat, reg=0.): """A node that represents the softmax loss. Should always be last node in a computational graph. Only useful for multinomial classification problems. """ Node.__init__(self, [y_hat]) self.y = y self.reg = reg
def reverseList(self, head): """ :param head: ListNode :return: ListNode """ dummyhead = Node() dummyhead.next = head cur = dummyhead.next pre = None while cur != None: next = cur.next cur.next = pre pre = cur cur = next dummyhead.next = pre return dummyhead
def __init__(self, node): """Compute the sigmoid of a given input node.""" Node.__init__(self, [node])
def __init__(self, *args): """A node that computes the linear combination of a list of input nodes features, a list of input weights, and a bias term.""" Node.__init__(self, [*args])
def __init__(self): """An input node. Input nodes don't perform any computations. Rather, they represent the input features that will be fed into the neural network. """ Node.__init__(self)
def __init__(self, y, y_hat): """A node that computes the mean squared error. Should only be used at the last node in a network.""" Node.__init__(self, [y, y_hat])
def __init__(self, node, epsilon=1e-4): """Computes rectified linear units for the node.""" Node.__init__(self, [node]) self.epsilon = epsilon
def __init__(self, node, epsilon=0., leak=1e-2): """Computes leaky rectified linear units for the node.""" Node.__init__(self, [node]) self.epsilon = epsilon self.leak = leak
def __init__(self, node): """A node that represents the softmax activation function. Should always be last node in a graph before computing loss, and only useful for probabilistic outputs between 0 and 1.""" Node.__init__(self, [node])