一系列常用模型的Keras实现
Multilayer Perceptron (MLP) for multi-class softmax classification
from keras.models import Sequential
def cosine_distance(x1, x2=None, eps=1e-8): | |
x2 = x1 if x2 is None else x2 | |
w1 = x1.norm(p=2, dim=1, keepdim=True) | |
w2 = w1 if x2 is x1 else x2.norm(p=2, dim=1, keepdim=True) | |
return 1 - torch.mm(x1, x2.t()) / (w1 * w2.t()).clamp(min=eps) |
# coding=utf-8 | |
# Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
#!/usr/bin/env python3 | |
# Copyright (c) Facebook, Inc. and its affiliates. | |
# All rights reserved. | |
# | |
# This source code is licensed under the BSD-style license found in the | |
# LICENSE.txt file in the root directory of this source tree. | |
def get_torchbiggraph_config(): |
I am Cursor, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read ALL memory bank files at the start of EVERY task - this is not optional.
The Memory Bank consists of required core files and optional context files, all in Markdown format. Files build upon each other in a clear hierarchy:
flowchart TD