repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/LoginConf.py
inter/LoginConf.py
# coding=utf-8 from config.urlConf import urls def loginConf(session): """ 判断登录是否需要验证码 :param session: :return: """ loginConfUrl = urls.get("loginConf") loginConfRsp = session.httpClint.send(urls=loginConfUrl, data={}) if loginConfRsp and loginConfRsp.get("data", {}).get("is_login_pass...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/ConfirmSingleForQueue.py
inter/ConfirmSingleForQueue.py
# coding=utf-8 import datetime import time from inter.CheckRandCodeAnsyn import checkRandCodeAnsyn from inter.GetPassengerDTOs import getPassengerDTOs from inter.GetRandCode import getRandCode from inter.QueryOrderWaitTime import queryOrderWaitTime class confirmSingleForQueue: def __init__(self, session, ifShowP...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/GetRepeatSubmitToken.py
inter/GetRepeatSubmitToken.py
# coding=utf-8 import json import re class getRepeatSubmitToken: def __init__(self, session): self.session = session def sendGetRepeatSubmitToken(self): """ 获取提交车票请求token :return: token """ initdc_url = self.session.urls["initdc_url"] initdc_result = se...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/AutoSubmitOrderRequest.py
inter/AutoSubmitOrderRequest.py
# coding=utf-8 import urllib from collections import OrderedDict from config.TicketEnmu import ticket from inter.CheckRandCodeAnsyn import checkRandCodeAnsyn from inter.GetQueueCountAsync import getQueueCountAsync from inter.GetRandCode import getRandCode import TickerConfig class autoSubmitOrderRequest: """ ...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/Query.py
inter/Query.py
# coding=utf-8 import copy import random import wrapcache from config import urlConf from config.TicketEnmu import ticket from myUrllib.httpUtils import HTTPClient from config.configCommon import seat_conf_2 import TickerConfig class query: """ 查询接口 """ def __init__(self, selectObj, from_station, to_...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/__init__.py
inter/__init__.py
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/GetPassCodeNewOrderAndLogin.py
inter/GetPassCodeNewOrderAndLogin.py
# coding=utf-8 import base64 import copy import random def getPassCodeNewOrderAndLogin(session, imgType): """ 下载验证码 :param session: :param imgType: 下载验证码类型,login=登录验证码,其余为订单验证码 :return: """ if imgType == "login": codeImgUrl = copy.deepcopy(session.urls["getCodeImg"]) codeIm...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/GetQueueCountAsync.py
inter/GetQueueCountAsync.py
import TickerConfig []# coding=utf-8 import datetime import sys import time from collections import OrderedDict import wrapcache from inter.ConfirmSingleForQueueAsys import confirmSingleForQueueAsys class getQueueCountAsync: """ 排队 """ def __init__(self, session, t...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/CheckOrderInfo.py
inter/CheckOrderInfo.py
# coding=utf-8 from collections import OrderedDict from inter.GetQueueCount import getQueueCount from inter.GetRepeatSubmitToken import getRepeatSubmitToken class checkOrderInfo: def __init__(self, session, train_no, set_type, passengerTicketStrList, oldPassengerStr, station_dates, ticket_peoples): self....
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/SubmitOrderRequest.py
inter/SubmitOrderRequest.py
# coding=utf-8 import datetime import urllib from collections import OrderedDict import TickerConfig from config.urlConf import urls from inter.CheckOrderInfo import checkOrderInfo from inter.ConfirmHB import confirmHB from inter.PassengerInitApi import passengerInitApi from myException.ticketIsExitsException import ti...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/GetSuccessRate.py
inter/GetSuccessRate.py
from collections import OrderedDict from config.urlConf import urls import TickerConfig from inter.SubmitOrderRequest import submitOrderRequestByAfterNate class getSuccessRate: def __init__(self, session, secretList): """ 获取成功信息 """ self.secretList = secretList self.sessi...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/inter/GetRandCode.py
inter/GetRandCode.py
# coding=utf-8 from PIL import Image from config.urlConf import urls from myUrllib.httpUtils import HTTPClient from verify.localVerifyCode import Verify import TickerConfig import os if TickerConfig.AUTO_CODE_TYPE == 2: v = Verify() def getRandCode(is_auto_code, auto_code_type, result): """ 识别验证码 :...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/UnitTest/__init__.py
UnitTest/__init__.py
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/UnitTest/TestAll.py
UnitTest/TestAll.py
# coding=utf-8 import base64 import threading import unittest from collections import OrderedDict import requests import TickerConfig from agency.agency_tools import proxy from config.emailConf import sendEmail from config.serverchanConf import sendServerChan from inter.LiftTicketInit import liftTicketInit def _set...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/agency/agency_tools.py
agency/agency_tools.py
# encoding=utf8 import os import random import socket import time import requests from bs4 import BeautifulSoup class proxy: def __init__(self): self.proxy_list = [] self.proxy_filter_list = [] def get_proxy(self): """ 获取未加工代理列表 :return: """ User_Agen...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/agency/cdn_utils.py
agency/cdn_utils.py
# encoding=utf8 import datetime import operator import os import requests from config import urlConf import threading from config.urlConf import urls from myUrllib.httpUtils import HTTPClient cdn_list = [] class CDNProxy(threading.Thread): def __init__(self, cdns): super().__init__() self.cdns =...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/agency/__init__.py
agency/__init__.py
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/configCommon.py
config/configCommon.py
# -*- coding: utf-8 -*- import datetime import os import random import sys import time from myException.ticketConfigException import ticketConfigException rushRefreshMinTimeIntval = 2000 rushRefreshMaxTimeIntval = 3600000 rushRefreshTimeIntval = 100 # 最早运行时间 maxRunTime = 6 # 程序停止时间 maxRunStopTime = 23 # 可售天数 maxDate ...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/pushbearConf.py
config/pushbearConf.py
# -*- coding: utf8 -*- import TickerConfig from config.urlConf import urls from myUrllib.httpUtils import HTTPClient PUSH_BEAR_API_PATH = "https://pushbear.ftqq.com/sub" def sendPushBear(msg): """ pushBear微信通知 :param str: 通知内容 content :return: """ if TickerConfig.PUSHBEAR_CONF["is_pushbear"] ...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/AutoSynchroTime.py
config/AutoSynchroTime.py
# coding=utf-8 import os import platform import ntplib import datetime def autoSynchroTime(): """ 同步北京时间,执行时候,请务必用sudo,sudo,sudo 执行,否则会报权限错误,windows打开ide或者cmd请用管理员身份 :return: """ c = ntplib.NTPClient() hosts = ['ntp1.aliyun.com', 'ntp2.aliyun.com', 'ntp3.aliyun.com', 'ntp4.aliyun.com', 'cn.p...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/getCookie.py
config/getCookie.py
import json import random import re import time import os import TickerConfig from config.urlConf import urls def getDrvicesID(session): """ :return: """ print("cookie获取中") if TickerConfig.COOKIE_TYPE is 1: from selenium import webdriver cookies = [] # 解决放镜像里 DevToolsActive...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/urlConf.py
config/urlConf.py
# coding=utf-8 import random import TickerConfig import time urls = { "auth": { # 登录接口 "req_url": "/passport/web/auth/uamtk", "req_type": "post", "Referer": "https://kyfw.12306.cn/otn/resources/login.html", "Host": "kyfw.12306.cn", "Content-Type": 1, "re_try": 10, ...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/logger.py
config/logger.py
#coding: utf-8 import os import time import logging from config import configCommon logger = None loggerHandler = None dateStr = '' #默认拥有日期后缀 suffix = '' #除了日期外的后缀 def setSuffix(s): global suffix suffix = s def getTodayDateStr(): return time.strftime("%Y-%m-%d", time.localtime(configCommon.getNowTimestamp())) ...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/serverchanConf.py
config/serverchanConf.py
# -*- coding: utf8 -*- import TickerConfig from config.urlConf import urls from myUrllib.httpUtils import HTTPClient PUSH_SERVER_CHAN_PATH = "https://sc.ftqq.com" def sendServerChan(msg): """ pushBear微信通知 :param str: 通知内容 content :return: """ if ( TickerConfig.SERVER_CHAN_CONF["is_ser...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/emailConf.py
config/emailConf.py
# -*- coding: utf8 -*- import socket __author__ = 'MR.wen' import TickerConfig from email.header import Header from email.mime.text import MIMEText import smtplib def sendEmail(msg): """ 邮件通知 :param str: email content :return: """ try: if TickerConfig.EMAIL_CONF["IS_MAIL"]: ...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/TicketEnmu.py
config/TicketEnmu.py
# coding=utf-8 from enum import Enum class ticket(object): QUERY_C = u"查询到有余票,尝试提交订单" QUERY_IN_BLACK_LIST = u"该车次{} 正在被关小黑屋,跳过此车次" SUCCESS_CODE = 000000 FAIL_CODE = 999999 AUTO_SUBMIT_ORDER_REQUEST_C = u"提交订单成功" AUTO_SUBMIT_ORDER_REQUEST_F = u"提交订单失败,重新刷票中" AUTO_SUBMIT_NEED_CODE = u"需要验证码...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/config/__init__.py
config/__init__.py
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/init/login.py
init/login.py
# -*- coding=utf-8 -*- import copy import time from collections import OrderedDict from time import sleep import TickerConfig from inter.GetPassCodeNewOrderAndLogin import getPassCodeNewOrderAndLogin1 from inter.GetRandCode import getRandCode from inter.LoginAysnSuggest import loginAysnSuggest from inter.LoginConf impo...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/init/select_ticket_info.py
init/select_ticket_info.py
# -*- coding=utf-8 -*- import datetime import random import os import socket import sys import threading import time import TickerConfig import wrapcache from agency.cdn_utils import CDNProxy, open_cdn_file from config import urlConf, configCommon from config.TicketEnmu import ticket from config.configCommon import sea...
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
testerSunshine/12306
https://github.com/testerSunshine/12306/blob/a495af88346a0d794493c6030f6a6207debb5824/init/__init__.py
init/__init__.py
python
MIT
a495af88346a0d794493c6030f6a6207debb5824
2026-01-04T14:42:34.772408Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/01-basics/linear_regression/main.py
tutorials/01-basics/linear_regression/main.py
import torch import torch.nn as nn import numpy as np import matplotlib.pyplot as plt # Hyper-parameters input_size = 1 output_size = 1 num_epochs = 60 learning_rate = 0.001 # Toy dataset x_train = np.array([[3.3], [4.4], [5.5], [6.71], [6.93], [4.168], [9.779], [6.182], [7.59], [2.167], [7.042]...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/01-basics/feedforward_neural_network/main.py
tutorials/01-basics/feedforward_neural_network/main.py
import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # Hyper-parameters input_size = 784 hidden_size = 500 num_classes = 10 num_epochs = 5 batch_size = 100 learning_rate = 0.001 ...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/01-basics/pytorch_basics/main.py
tutorials/01-basics/pytorch_basics/main.py
import torch import torchvision import torch.nn as nn import numpy as np import torchvision.transforms as transforms # ================================================================== # # Table of Contents # # ========================================================...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/01-basics/logistic_regression/main.py
tutorials/01-basics/logistic_regression/main.py
import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms # Hyper-parameters input_size = 28 * 28 # 784 num_classes = 10 num_epochs = 5 batch_size = 100 learning_rate = 0.001 # MNIST dataset (images and labels) train_dataset = torchvision.datasets.MNIST(root='../../data', ...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/neural_style_transfer/main.py
tutorials/03-advanced/neural_style_transfer/main.py
from __future__ import division from torchvision import models from torchvision import transforms from PIL import Image import argparse import torch import torchvision import torch.nn as nn import numpy as np # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') def load_image(...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/generative_adversarial_network/main.py
tutorials/03-advanced/generative_adversarial_network/main.py
import os import torch import torchvision import torch.nn as nn from torchvision import transforms from torchvision.utils import save_image # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # Hyper-parameters latent_size = 64 hidden_size = 256 image_size = 784 num_epochs = ...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/variational_autoencoder/main.py
tutorials/03-advanced/variational_autoencoder/main.py
import os import torch import torch.nn as nn import torch.nn.functional as F import torchvision from torchvision import transforms from torchvision.utils import save_image # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # Create a directory if not exists sample_dir = 'sam...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/image_captioning/data_loader.py
tutorials/03-advanced/image_captioning/data_loader.py
import torch import torchvision.transforms as transforms import torch.utils.data as data import os import pickle import numpy as np import nltk from PIL import Image from build_vocab import Vocabulary from pycocotools.coco import COCO class CocoDataset(data.Dataset): """COCO Custom Dataset compatible with torch.u...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/image_captioning/train.py
tutorials/03-advanced/image_captioning/train.py
import argparse import torch import torch.nn as nn import numpy as np import os import pickle from data_loader import get_loader from build_vocab import Vocabulary from model import EncoderCNN, DecoderRNN from torch.nn.utils.rnn import pack_padded_sequence from torchvision import transforms # Device configuration de...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/image_captioning/build_vocab.py
tutorials/03-advanced/image_captioning/build_vocab.py
import nltk import pickle import argparse from collections import Counter from pycocotools.coco import COCO class Vocabulary(object): """Simple vocabulary wrapper.""" def __init__(self): self.word2idx = {} self.idx2word = {} self.idx = 0 def add_word(self, word): if not wo...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/image_captioning/model.py
tutorials/03-advanced/image_captioning/model.py
import torch import torch.nn as nn import torchvision.models as models from torch.nn.utils.rnn import pack_padded_sequence class EncoderCNN(nn.Module): def __init__(self, embed_size): """Load the pretrained ResNet-152 and replace top fc layer.""" super(EncoderCNN, self).__init__() resnet =...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/image_captioning/resize.py
tutorials/03-advanced/image_captioning/resize.py
import argparse import os from PIL import Image def resize_image(image, size): """Resize an image to the given size.""" return image.resize(size, Image.ANTIALIAS) def resize_images(image_dir, output_dir, size): """Resize the images in 'image_dir' and save into 'output_dir'.""" if not os.path.exists(o...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/03-advanced/image_captioning/sample.py
tutorials/03-advanced/image_captioning/sample.py
import torch import matplotlib.pyplot as plt import numpy as np import argparse import pickle import os from torchvision import transforms from build_vocab import Vocabulary from model import EncoderCNN, DecoderRNN from PIL import Image # Device configuration device = torch.device('cuda' if torch.cuda.is_available...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/04-utils/tensorboard/logger.py
tutorials/04-utils/tensorboard/logger.py
# Code referenced from https://gist.github.com/gyglim/1f8dfb1b5c82627ae3efcfbbadb9f514 import tensorflow as tf import numpy as np import scipy.misc try: from StringIO import StringIO # Python 2.7 except ImportError: from io import BytesIO # Python 3.x class Logger(object): def __init__(self...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/04-utils/tensorboard/main.py
tutorials/04-utils/tensorboard/main.py
import torch import torch.nn as nn import torchvision from torchvision import transforms from logger import Logger # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # MNIST dataset dataset = torchvision.datasets.MNIST(root='../../data', ...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/02-intermediate/language_model/data_utils.py
tutorials/02-intermediate/language_model/data_utils.py
import torch import os class Dictionary(object): def __init__(self): self.word2idx = {} self.idx2word = {} self.idx = 0 def add_word(self, word): if not word in self.word2idx: self.word2idx[word] = self.idx self.idx2word[self.idx] = word ...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/02-intermediate/language_model/main.py
tutorials/02-intermediate/language_model/main.py
# Some part of the code was referenced from below. # https://github.com/pytorch/examples/tree/master/word_language_model import torch import torch.nn as nn import numpy as np from torch.nn.utils import clip_grad_norm_ from data_utils import Dictionary, Corpus # Device configuration device = torch.device('cuda' if to...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/02-intermediate/convolutional_neural_network/main.py
tutorials/02-intermediate/convolutional_neural_network/main.py
import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms # Device configuration device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') # Hyper parameters num_epochs = 5 num_classes = 10 batch_size = 100 learning_rate = 0.001 # MNIST dataset train_dataset = ...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/02-intermediate/bidirectional_recurrent_neural_network/main.py
tutorials/02-intermediate/bidirectional_recurrent_neural_network/main.py
import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # Hyper-parameters sequence_length = 28 input_size = 28 hidden_size = 128 num_layers = 2 num_classes = 10 batch_size = 100 nu...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/02-intermediate/recurrent_neural_network/main.py
tutorials/02-intermediate/recurrent_neural_network/main.py
import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # Hyper-parameters sequence_length = 28 input_size = 28 hidden_size = 128 num_layers = 2 num_classes = 10 batch_size = 100 nu...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
yunjey/pytorch-tutorial
https://github.com/yunjey/pytorch-tutorial/blob/0500d3df5a2a8080ccfccbc00aca0eacc21818db/tutorials/02-intermediate/deep_residual_network/main.py
tutorials/02-intermediate/deep_residual_network/main.py
# ---------------------------------------------------------------------------- # # An implementation of https://arxiv.org/pdf/1512.03385.pdf # # See section 4.2 for the model architecture on CIFAR-10 # # Some part of the code was referenced from below ...
python
MIT
0500d3df5a2a8080ccfccbc00aca0eacc21818db
2026-01-04T14:42:57.921424Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/train.py
train.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Legacy entry point. Use fairseq_cli/train.py or fairseq-train instead. """ from fairseq_cli.train import cli_mai...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/release_utils.py
release_utils.py
import argparse from typing import Tuple def get_next_version(release_type) -> Tuple[Tuple[int, int, int], str, str]: current_ver = find_version("fairseq/version.txt") version_list = [int(x) for x in current_ver.strip("'").split(".")] major, minor, patch = version_list[0], version_list[1], version_list[2]...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/setup.py
setup.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its 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 import subprocess import sys from setuptools import Extension, find_packages, setup from torch.utils import ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/hubconf.py
hubconf.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" import functools import importlib dependencies = [ "dataclasses", "hydra", "numpy", "omegaconf", "...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/shard_docs.py
scripts/shard_docs.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Split a large file into shards while respecting document boundaries. Documents should be separated by a single empty...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/check_installation.py
scripts/check_installation.py
from pathlib import Path import os cwd = Path(".").resolve() print("running 'check_installation.py' from:", cwd) # Old versions of numpy/torch can prevent loading the .so files import torch print("torch:", torch.__version__) import numpy print("numpy:", numpy.__version__) import fairseq print("Fairseq installed a...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/spm_train.py
scripts/spm_train.py
#!/usr/bin/env python # 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 absolute_import, division, print_function, unicode_literals import sys impor...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/rm_pt.py
scripts/rm_pt.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its 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 os import re import shutil import sys pt_regexp = re.compile(r"checkpoint(\d+|_\d+_\d+|_[a-z]+...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/count_docs.py
scripts/count_docs.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Count the number of documents and average number of lines and tokens per document in a large file. Documents should ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/compare_namespaces.py
scripts/compare_namespaces.py
#!/usr/bin/env python """Helper script to compare two argparse.Namespace objects.""" from argparse import Namespace # noqa def main(): ns1 = eval(input("Namespace 1: ")) ns2 = eval(input("Namespace 2: ")) def keys(ns): ks = set() for k in dir(ns): if not k.startswith("_"): ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/build_sym_alignment.py
scripts/build_sym_alignment.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Use this script in order to build symmetric alignments for your translation dataset. This script depends on fast_align and mosesdecoder too...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/__init__.py
scripts/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/spm_encode.py
scripts/spm_encode.py
#!/usr/bin/env python # 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 absolute_import, division, print_function, unicode_literals import argparse i...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/average_checkpoints.py
scripts/average_checkpoints.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its 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 collections import os import re import torch from fairseq.file_io import PathManager def ave...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/spm_decode.py
scripts/spm_decode.py
#!/usr/bin/env python # 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 absolute_import, division, print_function, unicode_literals import argparse ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/read_binarized.py
scripts/read_binarized.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its 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 from fairseq.data import Dictionary, data_utils, indexed_dataset def get_parser(): parser = argp...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/split_train_valid_docs.py
scripts/split_train_valid_docs.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Split a large file into a train and valid set while respecting document boundaries. Documents should be separated by...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/constraints/validate.py
scripts/constraints/validate.py
#!/usr/bin/env python3 # # Copyright (c) Facebook, Inc. and its 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 """Reads in a fairseq output file, and verifies that the constraints (C- lines) are present in the outpu...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/scripts/constraints/extract.py
scripts/constraints/extract.py
#!/usr/bin/env python3 # # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Extracts random constraints from reference files.""" import argparse import random import sys def get_phrase(wo...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/train.py
fairseq_cli/train.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Train a new model on one or across multiple GPUs. """ import argparse import logging import math import os impor...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/hydra_train.py
fairseq_cli/hydra_train.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its 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 os import hydra import torch from hydra.core.hydra_config import HydraConfig from omegaconf i...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/generate.py
fairseq_cli/generate.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Translate pre-processed data with a trained model. """ import ast import logging import math import os import sy...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/validate.py
fairseq_cli/validate.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its 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 os import sys from argparse import Namespace from itertools import chain import torch from om...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/interactive.py
fairseq_cli/interactive.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Translate raw text with a trained model. Batches data on-the-fly. """ import ast import fileinput import logging...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/hydra_validate.py
fairseq_cli/hydra_validate.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its 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 os import sys from itertools import chain import torch from hydra.core.hydra_config import Hy...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/__init__.py
fairseq_cli/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/score.py
fairseq_cli/score.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ BLEU scoring of generated translations against reference translations. """ import argparse import os import sys fr...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/eval_lm.py
fairseq_cli/eval_lm.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Evaluate the perplexity of a trained language model. """ import logging import math import os import sys from a...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq_cli/preprocess.py
fairseq_cli/preprocess.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Data pre-processing: build vocabularies and binarize training data. """ import logging import os import shutil impo...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/hydra_plugins/dependency_submitit_launcher/setup.py
hydra_plugins/dependency_submitit_launcher/setup.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # type: ignore from pathlib import Path from read_version import read_version from setuptools import find_namespace_packages, setup setup( name="dependency-submitit-launcher", version=read_version("hydra_plugins/dependency_submitit_launche...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/hydra_plugins/dependency_submitit_launcher/hydra_plugins/dependency_submitit_launcher/launcher.py
hydra_plugins/dependency_submitit_launcher/hydra_plugins/dependency_submitit_launcher/launcher.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import logging import os import subprocess from pathlib import Path from typing import Any, List, Sequence from hydra.core.singleton import Singleton from hydra.core.utils import JobReturn, filter_overrides from omegaconf import OmegaConf log = lo...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/hydra_plugins/dependency_submitit_launcher/hydra_plugins/dependency_submitit_launcher/config.py
hydra_plugins/dependency_submitit_launcher/hydra_plugins/dependency_submitit_launcher/config.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from dataclasses import dataclass, field from hydra.core.config_store import ConfigStore from hydra_plugins.hydra_submitit_launcher.config import SlurmQueueConf @dataclass class DependencySubmititConf(SlurmQueueConf): """Slurm configuration ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/hydra_plugins/dependency_submitit_launcher/hydra_plugins/dependency_submitit_launcher/__init__.py
hydra_plugins/dependency_submitit_launcher/hydra_plugins/dependency_submitit_launcher/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved __version__ = "0.1"
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_amp_optimizer.py
tests/test_amp_optimizer.py
# Copyright (c) Facebook, Inc. and its 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 copy import unittest import torch from torch.cuda.amp import GradScaler, autocast from fairseq.optim import build_opt...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_sequence_scorer.py
tests/test_sequence_scorer.py
# Copyright (c) Facebook, Inc. and its 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 unittest import tests.utils as test_utils import torch from fairseq.sequence_scorer import SequenceScorer class Test...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_data_utils.py
tests/test_data_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import numpy as np from fairseq.data.data_utils_fast import batch_by_size_fn, batch_by_size_vec class TestBatchBySize(unit...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_transformer.py
tests/test_transformer.py
import argparse import unittest from typing import Any, Dict, Sequence import torch from fairseq.models import transformer from tests.test_roberta import FakeTask def mk_sample(tok: Sequence[int] = None, batch_size: int = 2) -> Dict[str, Any]: if not tok: tok = [10, 11, 12, 13, 14, 15, 2] batch = t...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_inference_dropout.py
tests/test_inference_dropout.py
# Copyright (c) Facebook, Inc. and its 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 unittest from fairseq.dataclass.utils import convert_namespace_to_omegaconf from fairseq.models.transformer import Tran...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_roberta.py
tests/test_roberta.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import functools import unittest from typing import Any, Dict, Sequence import fairseq import fairseq.options import fairseq.tasks import tor...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_espnet_multihead_attention.py
tests/test_espnet_multihead_attention.py
import torch import numpy as np import unittest from fairseq.modules import ( ESPNETMultiHeadedAttention, RelPositionMultiHeadedAttention, RotaryPositionMultiHeadedAttention, ) torch.use_deterministic_algorithms(True) class TestESPNETMultiHeadedAttention(unittest.TestCase): def setUp(self) -> None: ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_metrics.py
tests/test_metrics.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import uuid from fairseq.logging import metrics class TestMetrics(unittest.TestCase): def test_nesting(self): w...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_file_io.py
tests/test_file_io.py
# This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import shutil import sys import tempfile import unittest from typing import Optional from unittest.mock import MagicMock class TestFileIO(unittest.TestCase): _tmpdir: Optional[st...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_sparse_multihead_attention.py
tests/test_sparse_multihead_attention.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention class TestSparseMultiheadAtten...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_rotary_positional_embedding.py
tests/test_rotary_positional_embedding.py
import torch import numpy as np import unittest from fairseq.modules.rotary_positional_embedding import apply_rotary_pos_emb from fairseq.modules import RotaryPositionalEmbedding class TestRotaryPositionalEmbedding(unittest.TestCase): def setUp(self) -> None: self.T = 3 self.B = 1 self.C =...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_ema.py
tests/test_ema.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from copy import deepcopy from dataclasses import dataclass import pytest from typing import Optional from unittest.mock impor...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_noising.py
tests/test_noising.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from typing import Dict, List import torch import tests.utils as test_utils from fairseq import utils from fairseq.data impo...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_convtbc.py
tests/test_convtbc.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch import torch.nn as nn from fairseq.modules import ConvTBC class TestConvTBC(unittest.TestCase): def test_c...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_concat_dataset.py
tests/test_concat_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest import torch from fairseq.data import LanguagePairDataset, TokenBlockDataset from fairseq.data.concat_dataset import ConcatDa...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/tests/test_export.py
tests/test_export.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its 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 tempfile import unittest import torch from fairseq.data.dictionary import Dictionary from fair...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false