python_code
stringlengths
0
4.04M
repo_name
stringlengths
7
58
file_path
stringlengths
5
147
import os import sys header = """Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ def prefixed_header(prefix): return [ prefix + l + "\n" for l in header.split("\n")] filename...
CollaQ-main
header.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import copy from components.episode_buffer import EpisodeBatch from modules.mixers.vdn import VDNMixer from modules.mixers.q...
CollaQ-main
src_code/learners/q_explore_learner.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import copy from components.episode_buffer import EpisodeBatch from modules.mixers.vdn import VDNMixer from modules.mixers.q...
CollaQ-main
src_code/learners/q_influence_learner.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import copy from components.episode_buffer import EpisodeBatch from modules.mixers.vdn import VDNMixer from modules.mixers.q...
CollaQ-main
src_code/learners/q_interactive_learner.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch.nn as nn import torch.nn.functional as F import torch as th class ScaledDotProductAttention(nn.Module): '...
CollaQ-main
src_code/modules/rnn_interactive_agent.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from modules.agents import REGISTRY as agent_REGISTRY from components.action_selectors import REGISTRY as action_REGISTRY im...
CollaQ-main
src_code/controllers/basic_controller_interactive.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from modules.agents import REGISTRY as agent_REGISTRY # from components.action_selectors import REGISTRY as action_REGISTR...
CollaQ-main
src_code/controllers/basic_controller_influence.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from setuptools import find_packages, setup setup( name='animated_drawings', description="Companion code for `A Method For Automatica...
AnimatedDrawings-main
setup.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.vectors import Vectors import numpy as np def test_initialize_with_tuple_or_list1(): v1 = Vectors((0, 1, 2)...
AnimatedDrawings-main
tests/test_vectors.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.bvh import BVH from pkg_resources import resource_filename def test_bvh_from_file(): bvh_fn = resource_file...
AnimatedDrawings-main
tests/test_bvh.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from animated_drawings.model.arap import ARAP, plot_mesh def test_single_triangle_mesh(): show_plots = False # Make ...
AnimatedDrawings-main
tests/test_arap.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.quaternions import Quaternions from animated_drawings.model.vectors import Vectors import numpy as np def test_...
AnimatedDrawings-main
tests/test_quaternions.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.animated_drawing import AnimatedDrawing from animated_drawings.config import Config from pkg_resources import res...
AnimatedDrawings-main
tests/test_animated_drawing.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings import render from pkg_resources import resource_filename import os import pytest @pytest.mark.skipif(os.environ.get(...
AnimatedDrawings-main
tests/test_render.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.transform import Transform from animated_drawings.model.quaternions import Quaternions import numpy as np def t...
AnimatedDrawings-main
tests/test_transforms.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from image_to_annotations import image_to_annotations from annotations_to_animation import annotations_to_animation from pathlib import Path i...
AnimatedDrawings-main
examples/image_to_animation.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import animated_drawings.render import logging from pathlib import Path import sys import yaml from pkg_resources import resource_filename d...
AnimatedDrawings-main
examples/annotations_to_animation.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import base64 from flask import Flask, render_template, request import json import os import sys import yaml global cfg_path ...
AnimatedDrawings-main
examples/fix_annotations.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys import requests import cv2 import json import numpy as np from skimage import measure from scipy import ndimage from pathlib import...
AnimatedDrawings-main
examples/image_to_annotations.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import logging from collections import defaultdict from pathlib import Path from typing import Union, List,...
AnimatedDrawings-main
animated_drawings/config.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import sys def start(user_mvc_cfg_fn: str): # build cfg from animated_drawings.config import Config cfg: Config ...
AnimatedDrawings-main
animated_drawings/render.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
AnimatedDrawings-main
animated_drawings/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from PIL import Image, ImageOps import numpy as np import numpy.typing as npt import cv2 from pathlib import Path import logging from pkg_reso...
AnimatedDrawings-main
animated_drawings/utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Controller Abstract Base Class Module """ from __future__ import annotations from typing import Optional from abc import abstractmethod i...
AnimatedDrawings-main
animated_drawings/controller/controller.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Interactive Controller Class Module """ import time from typing import Optional import glfw from animated_drawings.controller.controller...
AnimatedDrawings-main
animated_drawings/controller/interactive_controller.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Video Render Controller Class Module """ from __future__ import annotations import time import logging from typing import List from pathl...
AnimatedDrawings-main
animated_drawings/controller/video_render_controller.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations # so we can refer to class Type inside class import numpy as np import numpy.typing as npt import logging ...
AnimatedDrawings-main
animated_drawings/model/vectors.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import OpenGL.GL as GL import ctypes from animated_drawings.model.transform import Transform class Box(Transform): d...
AnimatedDrawings-main
animated_drawings/model/box.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations # so we can refer to class Type inside class import numpy as np import numpy.typing as npt import logging ...
AnimatedDrawings-main
animated_drawings/model/quaternions.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import ctypes import heapq import math import time from typing import Dict, List, Tuple, Optional, TypedDict, DefaultDict from ...
AnimatedDrawings-main
animated_drawings/model/animated_drawing.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations # so we can refer to class Type inside class import logging from pathlib import Path from typing import Li...
AnimatedDrawings-main
animated_drawings/model/bvh.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.transform import Transform from animated_drawings.model.time_manager import TimeManager from animated_drawings.co...
AnimatedDrawings-main
animated_drawings/model/scene.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.rectangle import Rectangle from animated_drawings.model.transform import Transform import numpy as np class Flo...
AnimatedDrawings-main
animated_drawings/model/floor.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.transform import Transform import numpy as np import numpy.typing as npt import OpenGL.GL as GL import ctypes c...
AnimatedDrawings-main
animated_drawings/model/transform_widget.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import numpy.typing as npt from collections import defaultdict import logging from typing import List, Dict, Set, Tuple imp...
AnimatedDrawings-main
animated_drawings/model/arap.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional from abc import abstractmethod class TimeManager(): """ Mixin class designed to be used by objects that must...
AnimatedDrawings-main
animated_drawings/model/time_manager.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.model.transform import Transform from animated_drawings.model.vectors import Vectors from typing import Union, List c...
AnimatedDrawings-main
animated_drawings/model/camera.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations # so we can refer to class Type inside class import numpy as np import numpy.typing as npt from animated_d...
AnimatedDrawings-main
animated_drawings/model/transform.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import OpenGL.GL as GL from animated_drawings.model.transform import Transform import ctypes class Rectangle(Transform): ...
AnimatedDrawings-main
animated_drawings/model/rectangle.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations from animated_drawings.model.transform import Transform from typing import List class Joint(Transform): ...
AnimatedDrawings-main
animated_drawings/model/joint.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from animated_drawings.model.bvh import BVH import numpy as np import numpy.typing as npt import math from animated_drawings.mo...
AnimatedDrawings-main
animated_drawings/model/retargeter.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from animated_drawings.view.view import View from animated_drawings.view.shaders.shader import Shader from animated_drawings.view.utils import...
AnimatedDrawings-main
animated_drawings/view/window_view.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations from abc import abstractmethod from typing import Tuple from animated_drawings.config import ViewConfig c...
AnimatedDrawings-main
animated_drawings/view/view.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import numpy.typing as npt import logging def get_projection_matrix(buffer_w: int, buffer_h: int, type_: str = 'perspecti...
AnimatedDrawings-main
animated_drawings/view/utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os os.environ['PYOPENGL_PLATFORM'] = "osmesa" os.environ['MESA_GL_VERSION_OVERRIDE'] = "3.3" from OpenGL import GL, osmesa from animat...
AnimatedDrawings-main
animated_drawings/view/mesa_view.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import OpenGL.GL as GL import logging class Shader: """Class to create shader programs""" @staticmethod def _compile_shader(src...
AnimatedDrawings-main
animated_drawings/view/shaders/shader.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import os import argparse from src.dataset import BinauralDataset from src.models import BinauralNetwork from src.trainer i...
BinauralSpeechSynthesis-main
train.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import os import argparse import numpy as np import torch as th import torchaudio as ta from src.models import BinauralNetw...
BinauralSpeechSynthesis-main
evaluate.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import torch as th import torch.nn as nn import torch.nn.functional as F class TimeWarperFunction(th.autograd.Function): ...
BinauralSpeechSynthesis-main
src/warping.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import numpy as np import scipy.linalg from scipy.spatial.transform import Rotation as R import torch as th import torch.nn ...
BinauralSpeechSynthesis-main
src/models.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import tqdm import torchaudio as ta import numpy as np class BinauralDataset: ''' dataset_directory: (str) base d...
BinauralSpeechSynthesis-main
src/dataset.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import numpy as np import torch as th import torch.nn as nn import torch.nn.functional as F class HyperConv(nn.Module): ...
BinauralSpeechSynthesis-main
src/hyperconv.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import numpy as np import torch as th import torchaudio as ta class Net(th.nn.Module): def __init__(self, model_name=...
BinauralSpeechSynthesis-main
src/utils.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import numpy as np import torch as th from src.utils import FourierTransform class Loss(th.nn.Module): def __init__(se...
BinauralSpeechSynthesis-main
src/losses.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ import tqdm import time import torch as th from torch.utils.data import DataLoader from src.utils import NewbobAdam from sr...
BinauralSpeechSynthesis-main
src/trainer.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 import torch from torch import nn from torch.nn import functional as F class AdaptiveEmbedding(...
adaptive-span-main
adaptive_io.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 # command-line arguments with their default values PARAMS_CONFIG = { # env-specific 'env...
adaptive-span-main
config.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 import math import torch import torch.nn as nn import torch.nn.functional as F class AdaptiveM...
adaptive-span-main
adaptive_span.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 import math import torch import torch.nn as nn import torch.nn.functional as F from adaptive_sp...
adaptive-span-main
models.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 import os import math import argparse import torch from adagrad_with_grad_clip import AdagradWit...
adaptive-span-main
utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 import math import random import torch def _train_step(model, X, Y, h_cache, eval_only, loss_...
adaptive-span-main
trainer.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 from argparse import Namespace import math import random import torch import torch.nn as nn impor...
adaptive-span-main
persistent_memory.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 import math import time import torch from config import PARAMS_CONFIG from data import get_trai...
adaptive-span-main
main.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 import os import torch class Dictionary(object): def __init__(self, path, sort_dict=False):...
adaptive-span-main
data.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #!/usr/bin/env python3 from torch.optim import Adagrad def _clip_grad(clr, grad, group_grad_clip): if group_grad_c...
adaptive-span-main
adagrad_with_grad_clip.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import html import json import os import re from lxml import etree def extract_text(input_text, keep_mar...
CCQA-main
python/closed_book_processing.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import html import json import multiprocessing import os import time import uuid im...
CCQA-main
python/mhtml_to_json.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import html import json import argparse import os import random import re import time from lxml import etree def extract...
CCQA-main
python/passage_retrieval_processing.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import copy import html import json import re import string from lxml import etree def extract_text(inpu...
CCQA-main
python/json_duplicate_filter.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import gzip import itertools import json import logging import os.path as osp import time import hydra import pandas as pd from omegaconf import DictConfig from tqdm import tqdm import numpy as np logger = logging.getLogger(__na...
cycle_gan_for_complementary_item_recommendations-main
src/main_process_meta.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time import types import hydra import pandas as pd import torch import torchvision.models as models from omegaconf import DictConfig from torch import Tensor from torch.utils.d...
cycle_gan_for_complementary_item_recommendations-main
src/main_create_embeddings.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import json import logging import os from os.path import join as osj from time import time import hydra import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytorch_lightning as pl import torch from omega...
cycle_gan_for_complementary_item_recommendations-main
src/main_inference_most_pop.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os.path as osp import random import pandas as pd import torch from PIL import Image from torch.utils.data import Dataset from torchvision import transforms logger = logging.getLogger(__name__) def load_df...
cycle_gan_for_complementary_item_recommendations-main
src/dataset_utils.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import json import logging import pandas as pd import torch from sklearn.metrics import ndcg_score from tqdm import tqdm import numpy as np from lit.eval_utils import calc_topk from os.path import join as osj from dataset_utils i...
cycle_gan_for_complementary_item_recommendations-main
src/inferece_utils.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time import hydra import numpy as np import pandas as pd import pytorch_lightning as pl from omegaconf import DictConfig from sklearn.model_selection import train_test_split f...
cycle_gan_for_complementary_item_recommendations-main
src/main_create_train_test_set.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time import hydra import pandas as pd import pytorch_lightning as pl import torch import torch.nn.functional as F import wandb from omegaconf import DictConfig, OmegaConf from...
cycle_gan_for_complementary_item_recommendations-main
src/main_execute_train_calssifier.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import itertools import logging import os import os.path as osp from os.path import join as osj from time import time import hydra import numpy as np import pytorch_lightning as pl import torch import wandb from omegaconf import ...
cycle_gan_for_complementary_item_recommendations-main
src/main_inference_gan.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp from time import time import hydra import pytorch_lightning as pl import torch import wandb from omegaconf import DictConfig, OmegaConf from pytorch_lightning.callbacks import Learnin...
cycle_gan_for_complementary_item_recommendations-main
src/main_execute_train.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import itertools import logging import os import os.path as osp from os.path import join as osj from time import time import hydra import numpy as np import pytorch_lightning as pl import torch import wandb from omegaconf import ...
cycle_gan_for_complementary_item_recommendations-main
src/main_inference_dcf.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time import urllib.request import hydra import pandas as pd from omegaconf import DictConfig from tqdm import tqdm from main_process_meta import reduce_to_closed_set, verify_c...
cycle_gan_for_complementary_item_recommendations-main
src/main_download_imgs.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import itertools import logging import os import os.path as osp from os.path import join as osj from time import time import hydra import numpy as np import pytorch_lightning as pl import torch import wandb from omegaconf import ...
cycle_gan_for_complementary_item_recommendations-main
src/main_inference_pcomp.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import time from os.path import join as osj from time import time from itertools import chain import numpy as np import pytorch_lightning as pl import torch import wandb from sklearn.metrics import ndcg_score from ...
cycle_gan_for_complementary_item_recommendations-main
src/lit/lit_utils.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import pytorch_lightning as pl import torch from torch import nn, optim logger = logging.getLogger(__name__) class LitImgClassifier(pl.LightningModule): def __init__(self, input_dim, num_classes, cfg): ...
cycle_gan_for_complementary_item_recommendations-main
src/lit/lit_img_classifier.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import time from os.path import join as osj from time import time import numpy as np import pytorch_lightning as pl import torch import wandb from sklearn.metrics import ndcg_score from torch import nn, optim from ...
cycle_gan_for_complementary_item_recommendations-main
src/lit/lit_pcomp.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import numpy as np import torch import pandas as pd from os.path import join as osj logger = logging.getLogger(__name__) def generate_test_set_hot_labels( asin_src_test: np.ndarray, category_pos_test: np...
cycle_gan_for_complementary_item_recommendations-main
src/lit/eval_utils.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import time from os.path import join as osj from time import time import numpy as np import pytorch_lightning as pl import torch import wandb from sklearn.metrics import ndcg_score from torch import nn, optim from...
cycle_gan_for_complementary_item_recommendations-main
src/lit/lit_dcf.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F class FastGradConv2dFunction(torch.autograd.Function)...
certified-removal-main
fast_grad_conv.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from __future__ import print_function import argparse import math import time import numpy as np import torch import torch...
certified-removal-main
test_removal.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F class Extractor(nn.Module): def __init__(self, nu...
certified-removal-main
models.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torchvision import torchvision.transforms as transforms import numpy as np import torch.nn as nn impor...
certified-removal-main
train_svhn.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F from fast_grad_conv import FastGradConv2d class FastG...
certified-removal-main
fast_grad_models.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import math import os import sys from fast_grad.goodfellow_backprop import goodfellow_backprop from torchvisi...
certified-removal-main
utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import numpy as np from tra...
certified-removal-main
test_func.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn.functional as F import math from utils import per_example_gradient, clip_and_sum_gradients, a...
certified-removal-main
train_func.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn.functional as F import pdb #debugging from goodfellow_backprop import goodfellow_backprop d...
certified-removal-main
fast_grad/gradient_funcs.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import pdb #debugging def goodfellow_backprop(activations, linearGrads): grads = [] for i in range(len(lin...
certified-removal-main
fast_grad/goodfellow_backprop.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import pdb import helpers from gradient_funcs import full, goodfellow, naive def runWith(N, D, L): X, y, model = helpers...
certified-removal-main
fast_grad/main.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from time import time from torch.nn.utils import parameters_to_vector, vector_to_parameters import cProfile, ...
certified-removal-main
fast_grad/helpers.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import sys import scip_solver as scip import xpress_solver as xp # Wrap is the various MILP solvers including SCIP...
CL-LNS-main
ilp_solver.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from numpy.lib.utils import byte_bounds class Solution: def __init__(self, model, scip_solution, obj_value): ...
CL-LNS-main
ilp_model.py