repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
castor | castor-main/castor/results/camus/image_attributes_plot.py | import itertools
from argparse import ArgumentParser
from pathlib import Path
from typing import Literal, Optional
import numpy as np
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt
from vital.data.camus.config import CamusTags
from castor.results.camus.utils.attributes_plot import Attr... | 4,371 | 38.035714 | 118 | py |
castor | castor-main/castor/results/camus/latent_space_attributes_plot.py | import math
from argparse import ArgumentParser
from pathlib import Path
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt
from castor.results.camus.utils.attributes_plot import AttributesPlots
from castor.results.camus.utils.latent_space_attributes import LatentSpaceAttributesMixin
cla... | 3,234 | 38.938272 | 119 | py |
castor | castor-main/castor/results/camus/utils/image_attributes.py | import logging
from argparse import ArgumentParser
from typing import Dict, Sequence
import numpy as np
from vital.data.camus.config import CamusTags
from vital.results.camus.utils.data_struct import ViewResult
from vital.results.processor import ResultsProcessor
logger = logging.getLogger(__name__)
class ImageAttr... | 2,342 | 35.609375 | 116 | py |
castor | castor-main/castor/results/camus/utils/latent_space_attributes.py | from argparse import ArgumentParser
from typing import Dict, Mapping
import numpy as np
from vital.data.camus.config import CamusTags
from vital.results.camus.utils.data_struct import ViewResult
from vital.results.processor import ResultsProcessor
from vital.utils.parsing import StoreDictKeyPair
class LatentSpaceAtt... | 2,583 | 42.066667 | 120 | py |
castor | castor-main/castor/results/camus/utils/temporal_metrics.py | from argparse import ArgumentParser
from pathlib import Path
from typing import Mapping, Optional, Tuple, Union
import numpy as np
import pandas as pd
import yaml
from vital import get_vital_root
from vital.metrics.evaluate.attribute import compute_temporal_consistency_metric
from vital.results.camus.utils.data_struct... | 9,257 | 49.315217 | 120 | py |
castor | castor-main/castor/results/camus/utils/__init__.py | 0 | 0 | 0 | py | |
castor | castor-main/castor/results/camus/utils/attributes_plot.py | from abc import abstractmethod
from argparse import ArgumentParser
from pathlib import Path
from typing import Dict, Sequence
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from vital.results.camus.utils.data_struct import ViewResult
from vital.results.camus.utils.itertools import PatientViews
... | 4,468 | 38.548673 | 120 | py |
castor | castor-main/castor/apps/__init__.py | 0 | 0 | 0 | py | |
castor | castor-main/castor/apps/autoencoder/latent_space_local_distribution.py | import argparse
import typing
from pathlib import Path
from typing import Any, Sequence
import h5py
import holoviews as hv
import numpy as np
import pandas as pd
import panel as pn
from panel.layout import Panel
from sklearn.neighbors import NearestNeighbors
from vital.tasks.autoencoder import SegmentationAutoencoderT... | 7,710 | 44.89881 | 120 | py |
castor | castor-main/castor/apps/autoencoder/latent_space_manipulation.py | import argparse
import typing
from pathlib import Path
from typing import Any
import holoviews as hv
import numpy as np
import pandas as pd
import panel as pn
from panel.layout import Panel
from vital.tasks.autoencoder import SegmentationAutoencoderTask
from vital.tasks.utils.autoencoder import decode, load_encodings,... | 6,108 | 40.557823 | 118 | py |
castor | castor-main/castor/apps/autoencoder/latent_space_attributes_sweeper.py | import argparse
import logging
import random
import typing
from pathlib import Path
from typing import Dict, Literal, Mapping, Sequence
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from matplotlib.axes import Axes
from vital.tasks.autoencoder import SegmentationAutoencoderTask
from vital... | 10,639 | 42.252033 | 120 | py |
castor | castor-main/castor/apps/autoencoder/latent_space_global_distribution.py | import argparse
import logging
import typing
from pathlib import Path
from typing import Any, Dict, Sequence
import h5py
import holoviews as hv
import numpy as np
import pandas as pd
import panel as pn
import umap
from holoviews import streams
from panel.layout import Panel
from vital.tasks.autoencoder import Segmenta... | 7,770 | 41.464481 | 120 | py |
castor | castor-main/castor/apps/autoencoder/__init__.py | 0 | 0 | 0 | py | |
openpose | openpose-master/examples/tutorial_api_python/openpose_python.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32":
# Cha... | 2,572 | 41.180328 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/05_keypoints_from_images_multi_gpu.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
import time
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32":
... | 4,276 | 37.881818 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/06_face_from_image.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
import time
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32":
... | 3,330 | 38.654762 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/01_body_from_image.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32":
# Cha... | 2,900 | 39.291667 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/08_heatmaps_from_image.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32":
# Cha... | 3,675 | 38.956522 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/02_whole_body_from_image.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32":
# Cha... | 3,146 | 39.87013 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/09_keypoints_from_heatmaps.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
import numpy as np
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32"... | 3,393 | 37.134831 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/07_hand_from_image.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
import time
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32":
... | 3,751 | 37.680412 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/12_asynchronous_custom_output.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
def display(datums):
datum = datums[0]
cv2.imshow("OpenPose 1.7.0 - Tutorial Python API", datum.cvOutputData)
key = cv2.waitKey(1)
return (key == 27)
def printKeypoints(da... | 3,345 | 36.177778 | 293 | py |
openpose | openpose-master/examples/tutorial_api_python/04_keypoints_from_images.py | # From Python
# It requires OpenCV installed for Python
import sys
import cv2
import os
from sys import platform
import argparse
import time
try:
# Import Openpose (Windows/Ubuntu/OSX)
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
# Windows Import
if platform == "win32":
... | 3,362 | 39.035714 | 293 | py |
openpose | openpose-master/python/openpose/__init__.py | from . import pyopenpose as pyopenpose
| 39 | 19 | 38 | py |
ReChorus | ReChorus-master/src/main.py | # -*- coding: UTF-8 -*-
import os
import sys
import pickle
import logging
import argparse
import pandas as pd
import torch
from helpers import *
from models.general import *
from models.sequential import *
from models.developing import *
from utils import utils
def parse_global_args(parser):
parser.add_argument... | 5,462 | 39.768657 | 102 | py |
ReChorus | ReChorus-master/src/exp.py | # -*- coding: UTF-8 -*-
import os
import subprocess
import pandas as pd
import argparse
import re
import traceback
import numpy as np
from typing import List
# Repeat experiments and save results to csv
# Example: python exp.py --in_f run.sh --out_f exp.csv --n 5
def parse_args():
parser = argparse.ArgumentPar... | 4,371 | 35.433333 | 104 | py |
ReChorus | ReChorus-master/src/helpers/BaseRunner.py | # -*- coding: UTF-8 -*-
import os
import gc
import torch
import torch.nn as nn
import logging
import numpy as np
from time import time
from tqdm import tqdm
from torch.utils.data import DataLoader
from typing import Dict, List
from utils import utils
from models.BaseModel import BaseModel
class BaseRunner(object):
... | 11,452 | 46.131687 | 124 | py |
ReChorus | ReChorus-master/src/helpers/SeqReader.py | # -*- coding: UTF-8 -*-
import logging
import pandas as pd
from helpers.BaseReader import BaseReader
class SeqReader(BaseReader):
def __init__(self, args):
super().__init__(args)
self._append_his_info()
def _append_his_info(self):
"""
self.user_his: store user history sequen... | 1,206 | 35.575758 | 88 | py |
ReChorus | ReChorus-master/src/helpers/KDAReader.py | # -*- coding: UTF-8 -*-
import os
import pickle
import argparse
import logging
import numpy as np
import pandas as pd
from tqdm import tqdm
from helpers.KGReader import KGReader
""" Data Reading for KDA """
class KDAReader(KGReader):
@staticmethod
def parse_data_args(parser):
parser.add_argument('--... | 4,574 | 41.757009 | 112 | py |
ReChorus | ReChorus-master/src/helpers/BUIRRunner.py | # -*- coding: UTF-8 -*-
import os
import gc
import torch
import torch.nn as nn
import logging
import numpy as np
from time import time
from tqdm import tqdm
from torch.utils.data import DataLoader
from utils import utils
from models.BaseModel import BaseModel
from helpers.BaseRunner import BaseRunner
class BUIRRunn... | 1,327 | 33.051282 | 104 | py |
ReChorus | ReChorus-master/src/helpers/KGReader.py | # -*- coding: UTF-8 -*-
import os
import pickle
import argparse
import logging
import numpy as np
import pandas as pd
from helpers.SeqReader import SeqReader
from utils import utils
class KGReader(SeqReader):
@staticmethod
def parse_data_args(parser):
parser.add_argument('--include_attr', type=int,... | 3,790 | 42.079545 | 107 | py |
ReChorus | ReChorus-master/src/helpers/__init__.py | from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [
basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')
]
| 217 | 26.25 | 84 | py |
ReChorus | ReChorus-master/src/helpers/BaseReader.py | # -*- coding: UTF-8 -*-
import os
import pickle
import argparse
import logging
import numpy as np
import pandas as pd
from utils import utils
class BaseReader(object):
@staticmethod
def parse_data_args(parser):
parser.add_argument('--path', type=str, default='../data/',
h... | 2,543 | 42.118644 | 120 | py |
ReChorus | ReChorus-master/src/models/__init__.py | 0 | 0 | 0 | py | |
ReChorus | ReChorus-master/src/models/BaseModel.py | # -*- coding: UTF-8 -*-
import torch
import logging
import numpy as np
from tqdm import tqdm
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset as BaseDataset
from torch.nn.utils.rnn import pad_sequence
from typing import List
from utils import utils
from helpers.BaseReader imp... | 9,962 | 39.173387 | 119 | py |
ReChorus | ReChorus-master/src/models/general/NeuMF.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" NeuMF
Reference:
"Neural Collaborative Filtering"
Xiangnan He et al., WWW'2017.
Reference code:
The authors' tensorflow implementation https://github.com/hexiangnan/neural_collaborative_filtering
CMD example:
python... | 2,848 | 36 | 103 | py |
ReChorus | ReChorus-master/src/models/general/BPRMF.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" BPRMF
Reference:
"Bayesian personalized ranking from implicit feedback"
Rendle et al., UAI'2009.
CMD example:
python main.py --model_name BPRMF --emb_size 64 --lr 1e-3 --l2 1e-6 --dataset 'Grocery_and_Gourmet_Food'
"""
... | 1,534 | 30.326531 | 108 | py |
ReChorus | ReChorus-master/src/models/general/BUIR.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" BUIR
Reference:
"Bootstrapping User and Item Representations for One-Class Collaborative Filtering"
Lee et al., SIGIR'2021.
CMD example:
python main.py --model_name BUIR --emb_size 64 --lr 1e-3 --l2 1e-6 --dataset 'Groc... | 4,676 | 39.318966 | 115 | py |
ReChorus | ReChorus-master/src/models/general/CFKG.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" CFKG
Reference:
"Learning over Knowledge-Base Embeddings for Recommendation"
Yongfeng Zhang et al., SIGIR'2018.
Note:
In the built-in dataset, we have four kinds of relations: buy, category, complement, substitute, wher... | 6,084 | 45.807692 | 115 | py |
ReChorus | ReChorus-master/src/models/general/DirectAU.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" DirectAU
Reference:
"Towards Representation Alignment and Uniformity in Collaborative Filtering"
Wang et al., KDD'2022.
CMD example:
python main.py --model_name DirectAU --dataset Grocery_and_Gourmet_Food \
... | 2,990 | 30.484211 | 82 | py |
ReChorus | ReChorus-master/src/models/general/LightGCN.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" LightGCN
Reference:
"LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation"
He et al., SIGIR'2020.
CMD example:
python main.py --model_name LightGCN --emb_size 64 --n_layers 3 --lr 1e-3 --l2 1e... | 4,769 | 34.597015 | 109 | py |
ReChorus | ReChorus-master/src/models/general/POP.py | # -*- coding: UTF-8 -*-
import torch
import numpy as np
from models.BaseModel import GeneralModel
class POP(GeneralModel):
"""
Recommendation according to item's popularity.
Should run with --train 0
"""
def __init__(self, args, corpus):
super().__init__(args, corpus)
self.popula... | 774 | 28.807692 | 75 | py |
ReChorus | ReChorus-master/src/models/general/__init__.py | from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [
basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')
]
| 217 | 26.25 | 84 | py |
ReChorus | ReChorus-master/src/models/developing/SRGNN.py | # -*- coding: UTF-8 -*-
import torch
from torch import nn
from torch.nn import Parameter
from torch.nn import functional as F
import numpy as np
from models.BaseModel import SequentialModel
class SRGNN(SequentialModel):
reader = 'SeqReader'
runner = 'BaseRunner'
extra_log_args = ['num_layers']
@sta... | 6,782 | 43.045455 | 114 | py |
ReChorus | ReChorus-master/src/models/developing/S3Rec.py | # -*- coding: UTF-8 -*-
import os
import logging
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from models.BaseModel import SequentialModel
from utils import layers
class S3Rec(SequentialModel):
reader = 'SeqReader'
runner = 'BaseRunner'
extra_log_args = ['emb_siz... | 10,204 | 46.465116 | 117 | py |
ReChorus | ReChorus-master/src/models/developing/FourierTA.py | # -*- coding: UTF-8 -*-
import torch
import torch.nn as nn
import numpy as np
from utils import layers
from models.BaseModel import SequentialModel
from helpers.KDAReader import KDAReader
class FourierTA(SequentialModel):
reader = 'SeqReader'
runner = 'BaseRunner'
extra_log_args = ['t_scalar']
@sta... | 5,011 | 40.421488 | 99 | py |
ReChorus | ReChorus-master/src/models/developing/__init__.py | from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [
basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')
]
| 217 | 26.25 | 84 | py |
ReChorus | ReChorus-master/src/models/developing/CLRec.py | # -*- coding: UTF-8 -*-
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from models.BaseModel import SequentialModel
from utils import layers
class CLRec(SequentialModel):
reader = 'SeqReader'
runner = 'BaseRunner'
extra_log_args = ['batch_size', 'temp']
@stati... | 5,081 | 35.826087 | 102 | py |
ReChorus | ReChorus-master/src/models/sequential/FPMC.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" FPMC
Reference:
"Factorizing Personalized Markov Chains for Next-Basket Recommendation"
Rendle et al., WWW'2010.
CMD example:
python main.py --model_name FPMC --emb_size 64 --lr 1e-3 --l2 1e-6 --history_max 20 \
--d... | 2,684 | 35.283784 | 114 | py |
ReChorus | ReChorus-master/src/models/sequential/SASRec.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" SASRec
Reference:
"Self-attentive Sequential Recommendation"
Kang et al., IEEE'2018.
Note:
When incorporating position embedding, we make the position index start from the most recent interaction.
CMD example:
pytho... | 3,606 | 38.637363 | 109 | py |
ReChorus | ReChorus-master/src/models/sequential/Caser.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" Caser
Reference:
"Personalized Top-N Sequential Recommendation via Convolutional Sequence Embedding"
Jiaxi Tang et al., WSDM'2018.
Reference code:
https://github.com/graytowne/caser_pytorch
Note:
We use a maximum of... | 4,363 | 41.368932 | 119 | py |
ReChorus | ReChorus-master/src/models/sequential/SLRCPlus.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" SLRC+
Reference:
"Modeling Item-specific Temporal Dynamics of Repeat Consumption for Recommender Systems"
Chenyang Wang et al., TheWebConf'2019.
Reference code:
The authors' tensorflow implementation https://github.com/... | 5,414 | 45.282051 | 111 | py |
ReChorus | ReChorus-master/src/models/sequential/NARM.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" NARM
Reference:
"Neural Attentive Session-based Recommendation"
Jing Li et al., CIKM'2017.
CMD example:
python main.py --model_name NARM --emb_size 64 --hidden_size 100 --attention_size 4 --lr 1e-3 --l2 1e-4 \
--his... | 3,776 | 43.435294 | 118 | py |
ReChorus | ReChorus-master/src/models/sequential/Chorus.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" Chorus
Reference:
"Make It a Chorus: Knowledge- and Time-aware Item Modeling for Sequential Recommendation"
Chenyang Wang et al., SIGIR'2020.
CMD example:
python main.py --model_name Chorus --emb_size 64 --margin 1 --lr... | 12,854 | 49.214844 | 119 | py |
ReChorus | ReChorus-master/src/models/sequential/ContraKDA.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" ContraKDA (KDA + ContraRec)
Reference:
"Toward Dynamic User Intention: Temporal Evolutionary Effects of Item Relations in Sequential Recommendation"
Chenyang Wang et al., TOIS'2021.
Sequential Recommendation with Multip... | 20,256 | 47.577938 | 116 | py |
ReChorus | ReChorus-master/src/models/sequential/TiMiRec.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" TiMiRec
Reference:
"Target Interest Distillation for Multi-Interest Recommendation"
Wang et al., CIKM'2022.
CMD example:
python main.py --model_name TiMiRec --dataset Grocery_and_Gourmet_Food \
--emb_... | 10,124 | 45.875 | 114 | py |
ReChorus | ReChorus-master/src/models/sequential/ContraRec.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" ContraRec
Reference:
"Sequential Recommendation with Multiple Contrast Signals"
Wang et al., TOIS'2022.
CMD example:
python main.py --model_name ContraRec --emb_size 64 --lr 1e-4 --l2 1e-6 --history_max 20 --encoder BER... | 11,519 | 40.588448 | 113 | py |
ReChorus | ReChorus-master/src/models/sequential/ComiRec.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" ComiRec
Reference:
"Controllable Multi-Interest Framework for Recommendation"
Cen et al., KDD'2020.
CMD example:
python main.py --model_name ComiRec --emb_size 64 --lr 1e-3 --l2 1e-6 --attn_size 8 --K 4 --add_pos 1 \
... | 3,848 | 39.946809 | 107 | py |
ReChorus | ReChorus-master/src/models/sequential/__init__.py | from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [
basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')
]
| 217 | 26.25 | 84 | py |
ReChorus | ReChorus-master/src/models/sequential/KDA.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" KDA
Reference:
"Toward Dynamic User Intention: Temporal Evolutionary Effects of Item Relations in Sequential Recommendation"
Chenyang Wang et al., TOIS'2021.
CMD example:
python main.py --model_name KDA --emb_size 64 --... | 15,388 | 49.621711 | 116 | py |
ReChorus | ReChorus-master/src/models/sequential/GRU4Rec.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" GRU4Rec
Reference:
"Session-based Recommendations with Recurrent Neural Networks"
Hidasi et al., ICLR'2016.
CMD example:
python main.py --model_name GRU4Rec --emb_size 64 --hidden_size 128 --lr 1e-3 --l2 1e-4 --history_... | 2,685 | 35.794521 | 110 | py |
ReChorus | ReChorus-master/src/models/sequential/TiSASRec.py | # -*- coding: UTF-8 -*-
# @Author : Chenyang Wang
# @Email : THUwangcy@gmail.com
""" TiSASRec
Reference:
"Time Interval Aware Self-Attention for Sequential Recommendation"
Jiacheng Li et al., WSDM'2020.
CMD example:
python main.py --model_name TiSASRec --emb_size 64 --num_layers 1 --num_heads 1 --lr 1e-... | 8,550 | 41.755 | 107 | py |
ReChorus | ReChorus-master/src/utils/utils.py | # -*- coding: UTF-8 -*-
import os
import random
import logging
import torch
import datetime
import numpy as np
import pandas as pd
from typing import List, Dict, NoReturn, Any
def init_seed(seed):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cu... | 3,723 | 33.803738 | 117 | py |
ReChorus | ReChorus-master/src/utils/layers.py | # -*- coding: UTF-8 -*-
import torch
import torch.nn as nn
import numpy as np
class MultiHeadAttention(nn.Module):
def __init__(self, d_model, n_heads, kq_same=False, bias=True):
super().__init__()
"""
It has projection layer for getting keys, queries and values. Followed by attention.
... | 3,225 | 36.08046 | 92 | py |
ReChorus | ReChorus-master/src/utils/__init__.py | 0 | 0 | 0 | py | |
CMCL-2022 | CMCL-2022-master/main.py | import torch
from base_model import Transformer
import pandas as pd
from base_dataset import CreateDataset
from sklearn.model_selection import train_test_split
from torch.utils.data import DataLoader
from tqdm import tqdm
from statistics import mean
from torchmetrics.functional import r2_score
import numpy as np
MAX_E... | 2,717 | 28.225806 | 94 | py |
CMCL-2022 | CMCL-2022-master/base_model.py |
from torch import nn
from transformers import AutoConfig, AutoModel
class Transformer(nn.Module):
def __init__(self, model, num_classes=1):
super().__init__()
self.name = model
config = AutoConfig.from_pretrained(self.name)
config.output_hidden_states = True
se... | 1,126 | 27.897436 | 109 | py |
CMCL-2022 | CMCL-2022-master/base_dataset.py | from torch.utils.data import Dataset
from transformers import AutoTokenizer
import torch
class CreateDataset(Dataset):
def __init__(self,data,labels,model):
super().__init__()
self.data = data
self.labels = labels
tokenizer = AutoTokenizer.from_pretrained(model)
self.encodin... | 723 | 44.25 | 150 | py |
CMCL-2022 | CMCL-2022-master/train_data_preprocessor.py | import pandas as pd
def get_sentence_number(s):
elements= s.split('-')
print(elements)
return int(elements[-1])
def get_text_name(s):
elements= s.split('-')
return '-'.join(elements[:-1])
df = pd.read_csv('data/test_data_subtask2/sub2/test.csv')
df['langText'] = df['sentence_id'].apply(get_text_n... | 447 | 27 | 64 | py |
CMCL-2022 | CMCL-2022-master/code/main.py | import pytorch_lightning as pl
from xlm_roberta import tfRegressor
import torch
from dataloader import TransduciveDataLoader
import pandas as pd
import numpy as np
langTexts = ['ZuCo1','ZuCo2','Provo','BSC','RSC','PAHEC','PoTeC','GECO-NL']
tf_name = 'xlm-roberta-base'
train_loc = 'data/training_data/train.csv'
val... | 1,246 | 27.340909 | 87 | py |
CMCL-2022 | CMCL-2022-master/code/trial.py | from transformers import AutoModel,AutoTokenizer
texts = [['Safe','to','say'],['Way','to','much']]
tf_name = 'xlm-roberta-base'
t = AutoTokenizer.from_pretrained(tf_name)
m = AutoModel.from_pretrained(tf_name)
e = t(texts[0],padding = 'max_length',is_split_into_words = True,max_length = 128,truncation = True,return_... | 457 | 37.166667 | 120 | py |
CMCL-2022 | CMCL-2022-master/code/dataloader.py | import pytorch_lightning as pl
import torch.utils.data as TorchData
import pandas as pd
from dataset import TransduciveDataset
from utils import getLangText,seperateHyphenToSentence
import numpy as np
class TransduciveDataLoader(pl.LightningDataModule):
def __init__(self,train_location,val_location,test_loc,langT... | 3,617 | 38.758242 | 99 | py |
CMCL-2022 | CMCL-2022-master/code/utils.py | def seperateHyphenToSentence(s):
parts = s.split('-')
return parts[-1]
def getLangText(s):
parts = s.split('-')
return '-'.join(parts[:-1])
| 156 | 21.428571 | 32 | py |
CMCL-2022 | CMCL-2022-master/code/dataset.py | import torch
from torch.utils.data import Dataset
from transformers import AutoTokenizer
MAX_LEN = 128
class TransduciveDataset(Dataset):
def __init__(self,texts,labels,mode ='train',tf_name = 'xlm-roberta-base') -> None:
super(TransduciveDataset,self).__init__()
try:
assert len(texts)... | 1,563 | 41.27027 | 167 | py |
CMCL-2022 | CMCL-2022-master/code/xlm_roberta.py | import pytorch_lightning as pl
from transformers import AutoModel,AutoTokenizer
import torch
import numpy as np
class tfRegressor(pl.LightningModule):
def __init__(self,lr,tf_name):
super(tfRegressor,self).__init__()
self.fe = AutoModel.from_pretrained(tf_name)
self.lr = lr
self.lin... | 2,701 | 34.552632 | 63 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/src/eval_metric.py | import numpy as np
def evaluate(predict_df, truth_df):
"""Compute MAE for each of the 4 variables."""
mae_FFDAvg = np.abs(predict_df['FFDAvg'] - truth_df['FFDAvg']).mean()
mae_FFDStd = np.abs(predict_df['FFDStd'] - truth_df['FFDStd']).mean()
mae_TRTAvg = np.abs(predict_df['TRTAvg'] - truth_df['TRTAvg']).mean()... | 693 | 37.555556 | 71 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/src/dataloader.py | import torch
import transformers
FEATURES_NAMES = ['FFDAvg', 'FFDStd', 'TRTAvg', 'TRTStd']
class EyeTrackingCSV(torch.utils.data.Dataset):
"""Tokenize sentences and load them into tensors. Assume dataframe has sentence_id."""
def __init__(self, df, mode = 'train',model_name='roberta-base'):
self.model_name =... | 3,140 | 34.292135 | 110 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/src/model.py | import random
import numpy as np
import torch
import transformers
from tqdm import tqdm
import src.dataloader
device = torch.device('cuda:1')
class RobertaRegressionModel(torch.nn.Module):
def __init__(self, model_name='roberta-base'):
super(RobertaRegressionModel, self).__init__()
if 'roberta' in model_n... | 9,123 | 36.240816 | 104 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/scripts/run_roberta.py | import sys
sys.path.append('../')
import pandas as pd
import argparse
import src.model
parser = argparse.ArgumentParser()
parser.add_argument('--num-ensembles', type=int)
parser.add_argument('--use-provo', type=bool)
# dev: use our own train/valid split
# submission: use all data and make predictions on unknown d... | 1,157 | 25.318182 | 70 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/scripts/ensemble.py | import pandas as pd
import glob
import src.eval_metric
import src.dataloader
all_predictions = [pd.read_csv(f) for f in glob.glob('scripts/predict-*.csv')]
all_predictions = pd.concat(all_predictions)
mean_df = all_predictions.groupby(['sentence_id', 'word_id', 'word']).mean().reset_index()
df_num = mean_df[src.datal... | 532 | 30.352941 | 90 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/notebooks/RoBERTaRegression.py | #!/usr/bin/env python
# coding: utf-8
# # RoBERTa Regression
# In[1]:
import sys
sys.path.append('../')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import tqdm
import torch
from collections import defaultdict, Counter
import random
import math
import pickle
import ... | 1,196 | 13.597561 | 57 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/notebooks/ProvoProcess.py | #!/usr/bin/env python
# coding: utf-8
# # Process Provo Corpus
# In[1]:
import sys
sys.path.append('../')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import tqdm
import torch
from collections import defaultdict, Counter
import random
import math
import pickle
get_i... | 2,710 | 21.591667 | 146 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/notebooks/InitialExplore.py | #!/usr/bin/env python
# coding: utf-8
# # Some initial exploration
# In[1]:
import sys
sys.path.append('../')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import tqdm
import torch
from collections import defaultdict, Counter
import random
import math
import pickle
g... | 1,094 | 16.380952 | 79 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/notebooks/MedianBaseline.py | #!/usr/bin/env python
# coding: utf-8
# # Median Baseline
# In[1]:
import sys
sys.path.append('../')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import tqdm
import torch
from collections import defaultdict, Counter
import random
import math
import pickle
import stri... | 2,091 | 17.678571 | 73 | py |
CMCL-2022 | CMCL-2022-master/cmcl-shared-task-main/notebooks/RobertaRegression.py | # %% [markdown]
# # RoBERTa Regression
# %%
import sys
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import tqdm
import torch
from collections import defaultdict, Counter
import random
import math
import pickle
import os
import src.eval_metric
import src.model
import sr... | 914 | 15.339286 | 60 | py |
CMCL-2022 | CMCL-2022-master/data/join_data_pred.py | import os
import pandas as pd
def joinToCreate(text,sentence):
return '-'.join([text,sentence])
texts = ['ZuCo1' ,'ZuCo2', 'Provo', 'BSC' ,'RSC', 'PAHEC', 'PoTeC', 'GECO-NL']
files = {}
PRED_DIR = 'task1_predictions/'
for text in texts:
file = pd.read_csv(PRED_DIR+text+'_predictions.csv')
ser = []
f... | 486 | 24.631579 | 78 | py |
CMCL-2022 | CMCL-2022-master/data/task2_predictions/ensemble.py | import pandas as pd
import glob
FEATURES_NAMES = ['FFDAvg', 'FFDStd', 'TRTAvg', 'TRTStd']
all_predictions = [pd.read_csv(f) for f in glob.glob('predictions*.csv')]
for pred in all_predictions:
pred.drop(columns = ['langText'],inplace = True)
# all_predictions = pd.concat(all_predictions)
# mean_df = all_predict... | 549 | 29.555556 | 103 | py |
RESPECT | RESPECT-main/reinforce_baselines.py | import torch
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from scipy.stats import ttest_rel
import copy
from train import rollout, get_inner_model
class Baseline(object):
def wrap_dataset(self, dataset):
return dataset
def unwrap_batch(self, batch):
return ... | 8,641 | 32.890196 | 121 | py |
RESPECT | RESPECT-main/run.py | #!/usr/bin/env python
import os
import json
import pprint as pp
import torch
import torch.optim as optim
from tensorboard_logger import Logger as TbLogger
from nets.critic_network import CriticNetwork
from options import get_options
from train import train_epoch, validate, get_inner_model
#from train_single import t... | 7,073 | 36.231579 | 137 | py |
RESPECT | RESPECT-main/train_model_run.py | import os
import time
from tqdm import tqdm
import torch
import math
from torch.utils.data import DataLoader
from torch.nn import DataParallel
from nets.attention_model import set_decode_type
from utils.log_utils import log_values
from utils import move_to
import warnings
def get_inner_model(model):
return mode... | 11,203 | 43.995984 | 243 | py |
RESPECT | RESPECT-main/options.py | import os
import time
import argparse
import torch
def get_options(args=None):
parser = argparse.ArgumentParser(
description="Attention based model for solving the Travelling Salesman Problem with Reinforcement Learning")
# Data
parser.add_argument('--problem', default='toposort', help="The probl... | 6,946 | 69.887755 | 134 | py |
RESPECT | RESPECT-main/reinforce_baselines_single.py | import torch
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from scipy.stats import ttest_rel
import copy
from train import rollout, get_inner_model
class Baseline(object):
def wrap_dataset(self, dataset):
return dataset
def unwrap_batch(self, batch):
return ... | 8,641 | 32.890196 | 121 | py |
RESPECT | RESPECT-main/train.py | import os
import time
from tqdm import tqdm
import torch
import math
from torch.utils.data import DataLoader
from torch.nn import DataParallel
from nets.attention_model import set_decode_type
from utils.log_utils import log_values
from utils import move_to
import warnings
def get_inner_model(model):
return mode... | 12,296 | 45.579545 | 295 | py |
RESPECT | RESPECT-main/dataset/dataset_generator.py | from torch.utils.data import Dataset
import torch, random
import os
import pickle
#from problems.toposort.state_toposort import StateTopoSort
#from utils.beam_search import beam_search
#from utils import orderCheck, deep_sort_x, level_sorting, level_sorting_xy_pairs, order_check, graph_sorting_DAG
from collections imp... | 22,823 | 67.954683 | 229 | py |
RESPECT | RESPECT-main/dataset/__init__.py | from dataset.dataset_generator import TopoSortDataset
| 54 | 26.5 | 53 | py |
RESPECT | RESPECT-main/nets/pointer_network_singleTraining.py | import torch
import torch.nn as nn
from torch.autograd import Variable
import math
import numpy as np
from torch.nn import TransformerEncoder, TransformerEncoderLayer
from utils import move_to
class Encoder(nn.Module):
"""Maps a graph represented as an input sequence
to a hidden vector"""
def __init__(se... | 16,623 | 40.25062 | 198 | py |
RESPECT | RESPECT-main/nets/pointer_network.py | import torch
import torch.nn as nn
from torch.autograd import Variable
import math
import numpy as np
from torch.nn import TransformerEncoder, TransformerEncoderLayer
from utils import move_to
class Encoder(nn.Module):
"""Maps a graph represented as an input sequence
to a hidden vector"""
def __init__(se... | 16,623 | 40.25062 | 198 | py |
RESPECT | RESPECT-main/nets/pointer_network_originalbatch.py | import torch
import torch.nn as nn
from torch.autograd import Variable
import math
import numpy as np
from torch.nn import TransformerEncoder, TransformerEncoderLayer
from utils import move_to
class Encoder(nn.Module):
"""Maps a graph represented as an input sequence
to a hidden vector"""
def __init__(se... | 16,271 | 40.510204 | 198 | py |
RESPECT | RESPECT-main/nets/pointer_network_model_run.py | import torch
import torch.nn as nn
from torch.autograd import Variable
import math
import numpy as np
from torch.nn import TransformerEncoder, TransformerEncoderLayer
from utils import move_to
class Encoder(nn.Module):
"""Maps a graph represented as an input sequence
to a hidden vector"""
def __init__(se... | 16,348 | 40.600509 | 198 | py |
RESPECT | RESPECT-main/nets/attention_model.py | import torch
from torch import nn
from torch.utils.checkpoint import checkpoint
import math
from typing import NamedTuple
from utils.tensor_functions import compute_in_batches
from nets.graph_encoder import GraphAttentionEncoder
from torch.nn import DataParallel
from utils.beam_search import CachedLookup
from utils.fu... | 22,485 | 42.49323 | 122 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.