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 |
|---|---|---|---|---|---|---|
sarpy | sarpy-master/sarpy/io/DEM/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/consistency/sicd_consistency.py | """
A module for performing a selection of validation checks on a SICD (nitf) file,
or the xml file containing the sicd structure.
Use the `check_file` function directly, or perform using the command line
>>> python -m sarpy.consistency.sicd_consistency <file_name>
For more information, about command line usage, see... | 15,087 | 37.197468 | 115 | py |
sarpy | sarpy-master/sarpy/consistency/consistency.py | #
# Copyright 2020-2021 Valkyrie Systems Corporation
#
# Licensed under MIT License. See LICENSE.
#
__classification__ = "UNCLASSIFIED"
__author__ = "Nathan Bombaci, Valkyrie"
import collections
import contextlib
import linecache
import re
import sys
import textwrap
from typing import List, Dict
import numpy as np... | 15,118 | 29.298597 | 119 | py |
sarpy | sarpy-master/sarpy/consistency/cphd_consistency.py | #
# Copyright 2020-2021 Valkyrie Systems Corporation
#
# Licensed under MIT License. See LICENSE.
#
__classification__ = "UNCLASSIFIED"
__author__ = "Nathan Bombaci, Valkyrie"
import logging
import argparse
import collections
import copy
import functools
import itertools
import numbers
import os
import re
from typi... | 85,361 | 42.133906 | 120 | py |
sarpy | sarpy-master/sarpy/consistency/parsers.py | #
# Copyright 2020-2021 Valkyrie Systems Corporation
#
# Licensed under MIT License. See LICENSE.
#
__classification__ = "UNCLASSIFIED"
__author__ = "Nathan Bombaci, Valkyrie"
from typing import List
import numpy as np
def parse_text(elem):
"""
Reverse of `xml.make_elem` by converting an element's text st... | 4,465 | 21 | 91 | py |
sarpy | sarpy-master/sarpy/consistency/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/consistency/sidd_consistency.py | """
A module for performing a selection of validation checks on a SIDD (nitf) file,
or an xml file containing the sidd structure.
Use the `check_file` function directly, or perform using the command line
>>> python -m sarpy.consistency.sidd_consistency <file_name>
For more information, about command line usage, see
... | 16,149 | 38.68059 | 120 | py |
sarpy | sarpy-master/sarpy/geometry/point_projection.py | """
Functions to map between the coordinates in image pixel space and geographical
coordinates.
Examples
--------
.. code-block:: python
from sarpy.geometry import point_projection
from sarpy.io.complex.sicd import SICDReader
reader = SICDReader('<path to sicd file>')
structure = reader.sicd_meta
... | 75,489 | 37.574348 | 152 | py |
sarpy | sarpy-master/sarpy/geometry/geometry_elements.py | """
This module provides basic geometry elements generally geared towards (geo)json usage.
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import copy
from collections import OrderedDict
from uuid import uuid4
from typing import Union, List, Tuple, Dict, Callable, Any
import json
import loggi... | 78,840 | 30.423276 | 119 | py |
sarpy | sarpy-master/sarpy/geometry/latlon.py | """
Module for converting between various latitude/longitude representations.
"""
import re
import numpy
__classification__ = "UNCLASSIFIED"
__author__ = "Wade Schwartzkopf"
def string(value, latlon, num_units=3, precision=None, delimiter='',
include_symbols=True, signed=False, padded=True):
"""
... | 7,323 | 34.726829 | 111 | py |
sarpy | sarpy-master/sarpy/geometry/__init__.py |
__classification__ = "UNCLASSIFIED"
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/geometry/geocoords.py | """
Provides coordinate transforms for WGS-84 and ECF coordinate systems
"""
import numpy
__classification__ = "UNCLASSIFIED"
__author__ = ("Thomas McCullough", "Wade Schwartzkopf")
#####
# WGS-84 parameters and related derived parameters
_A = 6378137.0 # Semi-major radius (m)
_F = 1/298.257223563 # ... | 10,143 | 29.926829 | 112 | py |
sarpy | sarpy-master/sarpy/visualization/kmz_product_creation.py | """
This module provides tools for creating kmz products for a SICD type element.
.. Note::
Creation of ground overlays (i.e. image overlay) requires the optional
Pillow dependency for image manipulation.
Examples
--------
Create a kmz overview for the contents of a sicd type reader.
.. code-block:: python
... | 24,512 | 33.283916 | 159 | py |
sarpy | sarpy-master/sarpy/visualization/cphd_kmz_product_creation.py | """
This module provides tools for creating kmz products for a CPHD type element.
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Valkyrie Systems Corporation"
import logging
import os
import matplotlib.pyplot as plt
import numpy as np
from sarpy.io.kml import Document
from sarpy.geometry.geocoords import ecf... | 24,545 | 34.625544 | 172 | py |
sarpy | sarpy-master/sarpy/visualization/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/visualization/remap.py | """
Provides common methods for remapping a complex or other array to 8 or 16-bit
image type arrays.
Note: The original function and 8-bit implementation has been replaced with a
class based solution which allows state variables associated with the remap
function, and support for 16-bit versions, as well as an 8-bit M... | 61,734 | 30.904393 | 126 | py |
sarpy | sarpy-master/sarpy/utils/create_kmz.py | """
Create kmz products based on CPHD or SICD.
For a basic help on the command-line, check
>>> python -m sarpy.utils.create_kmz --help
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import argparse
import logging
import os
import sarpy
from sarpy.io.complex.converter import open_complex
... | 2,529 | 39.15873 | 117 | py |
sarpy | sarpy-master/sarpy/utils/nitf_utils.py | """
A utility for dumping a NITF header to the console. Contributed by Austin Lan of L3/Harris.
To dump NITF header information to a text file from the command-line
>>> python -m sarpy.utils.nitf_utils <path to nitf file>
For a basic help on the command-line, check
>>> python -m sarpy.utils.nitf_utils --help
"""
... | 17,560 | 35.283058 | 117 | py |
sarpy | sarpy-master/sarpy/utils/create_product.py | """
Create products based on SICD type reader.
For a basic help on the command-line, check
>>> python -m sarpy.utils.create_product --help
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import argparse
import logging
import sarpy
from sarpy.io.complex.converter import open_complex
from s... | 3,545 | 41.214286 | 121 | py |
sarpy | sarpy-master/sarpy/utils/nominal_sicd_noise.py | """
Add a nominal noise polynomial to a sicd.
For a basic help on the command-line, check
>>> python -m sarpy.utils.nominal_sicd_noise --help
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
import os
import argparse
import numpy
import sarpy
from sarpy.io.complex.sicd imp... | 5,484 | 35.566667 | 103 | py |
sarpy | sarpy-master/sarpy/utils/convert_to_sicd.py | """
Convert from complex SAR image format to SICD format.
For a basic help on the command-line, check
>>> python -m sarpy.utils.convert_to_sicd --help
"""
__classification__ = "UNCLASSIFIED"
__author__ = ("Thomas McCullough", "Valkyrie Systems Corporation")
import argparse
import logging
import sarpy
from sarpy.i... | 6,083 | 48.463415 | 117 | py |
sarpy | sarpy-master/sarpy/utils/review_class.py | from __future__ import print_function
import sys
import functools
from collections import defaultdict
import pkgutil
from importlib import import_module
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
print_func = print
def traverse_module_classification(package_name, results_dict):
def e... | 2,415 | 31.648649 | 98 | py |
sarpy | sarpy-master/sarpy/utils/chip_sicd.py | """
Create a chip (subimage) of a SICD image.
For a basic help on the command-line, check
>>> python -m sarpy.utils.chip_sicd --help
"""
__classification__ = "UNCLASSIFIED"
__author__ = "John Gorman"
import os
import argparse
from typing import Tuple
import logging
import sarpy
from sarpy.io.complex.converter imp... | 5,388 | 34.688742 | 99 | py |
sarpy | sarpy-master/sarpy/utils/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/utils/cphd_utils.py | """
Extract information from the CPHD header for review.
From the command-line
>>> python -m sarpy.utils.cphd_utils <path to cphd file>
For a basic help on the command-line, check
>>> python -m sarpy.utils.cphd_utils --help
"""
from __future__ import print_function
import argparse
import sys
import functools
from... | 7,698 | 27.835206 | 107 | py |
sarpy | sarpy-master/sarpy/processing/rational_polynomial.py | """
General purpose rational polynomial tools
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
from typing import List, Tuple, Sequence, Optional, Union
import numpy
from numpy.polynomial import polynomial
from scipy.linalg import lstsq, LinAlgError
from sarpy.compliance impor... | 24,428 | 31.270806 | 120 | py |
sarpy | sarpy-master/sarpy/processing/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/processing/registration/regi.py | """
Basic image registration, generally best suited most suited for coherent image
collection. This is based pretty directly on an approach developed at Sandia and
generally referred to by the name "regi".
The relevant matlab code appears to be authored by Terry M. Calloway,
Sandia National Laboratories, and modified ... | 22,629 | 39.996377 | 146 | py |
sarpy | sarpy-master/sarpy/processing/registration/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/processing/registration/basic.py | """
Basic image registration tools
"""
__classification__ = "UNCLASSIFIED"
__author__ = 'Thomas McCullough'
import logging
from typing import Sequence, Union, Tuple, Any
import numpy
from scipy.optimize import minimize
from sarpy.io.complex.sicd_elements.SICD import SICDType
from sarpy.io.product.sidd1_elements.SID... | 10,192 | 35.403571 | 103 | py |
sarpy | sarpy-master/sarpy/processing/sicd/subaperture.py | """
Sub-aperture processing methods.
"""
__author__ = 'Thomas McCullough'
__classification__ = "UNCLASSIFIED"
import logging
from typing import Union, Generator, Tuple, List, Optional, Sequence
import numpy
from scipy.constants import speed_of_light
from sarpy.processing.sicd.fft_base import FFTCalculator, fft, if... | 34,669 | 36.400216 | 117 | py |
sarpy | sarpy-master/sarpy/processing/sicd/normalize_sicd.py | """
Methods for transforming SICD data to a common state.
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
from tempfile import mkstemp
import os
from typing import Dict, Tuple, Optional, Union
import numpy
from numpy.polynomial import polynomial
from numpy.random import randn
... | 47,145 | 39.819048 | 137 | py |
sarpy | sarpy-master/sarpy/processing/sicd/rgiqe.py | """
Radar Generalized Image Quality Equation (RGIQE) calculation(s) and tools for
application to SICD structures and files.
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
from typing import Union, Tuple, Dict, Optional
import numpy
from sarpy.io.complex.base import SICDType... | 34,889 | 34.385396 | 113 | py |
sarpy | sarpy-master/sarpy/processing/sicd/ccd.py | """
The module contains methods for computing a coherent change detection from registered images
"""
from typing import Union, Tuple
import numpy
import scipy.signal
__classification__ = "UNCLASSIFIED"
__author__ = ('Thomas Mccullough', 'Wade Schwartzkopf', 'Mike Dowell')
def mem(
reference_image: numpy.n... | 2,535 | 36.850746 | 109 | py |
sarpy | sarpy-master/sarpy/processing/sicd/windows.py | """
Window function definitions and a few helper functions. This just passes through
to scipy functions after managing scipy version dependent import structure.
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
from typing import Union, Optional
import scipy
import numpy
from scipy.optimize im... | 8,269 | 27.419244 | 106 | py |
sarpy | sarpy-master/sarpy/processing/sicd/csi.py | """
The methods for computing a color sub-aperture image for SICD type images.
As noted in the CSICalculator class, the full resolution data along the split dimension
is required, so sub-sampling along the split dimension does not decrease the amount of
data which must be fetched and/or processing which must be perfor... | 13,313 | 37.479769 | 108 | py |
sarpy | sarpy-master/sarpy/processing/sicd/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/processing/sicd/fft_base.py | """
Helper classes and methods for Fourier processing schemes.
"""
__classification__ = "UNCLASSIFIED"
__author__ = 'Thomas McCullough'
import logging
from typing import Union
from sarpy.io.complex.base import SICDTypeReader
from sarpy.io.complex.sicd_elements.SICD import SICDType
from sarpy.processing.ortho_rectify... | 7,595 | 25.840989 | 108 | py |
sarpy | sarpy-master/sarpy/processing/ortho_rectify/base.py | """
Common ortho-rectification elements
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
import os
from typing import Union, Tuple, List, Optional, Sequence
import numpy
from sarpy.io.complex.converter import open_complex
from sarpy.io.complex.sicd_elements.SICD import SICDTyp... | 24,625 | 34.280802 | 115 | py |
sarpy | sarpy-master/sarpy/processing/ortho_rectify/__init__.py |
__classification__ = 'UNCLASSIFIED'
from .base import FullResolutionFetcher, OrthorectificationIterator
from .ortho_methods import OrthorectificationHelper, NearestNeighborMethod, BivariateSplineMethod
from .projection_helper import ProjectionHelper, PGProjection, PGRatPolyProjection
| 287 | 40.142857 | 97 | py |
sarpy | sarpy-master/sarpy/processing/ortho_rectify/projection_helper.py | """
Unified methods of projection between sicd pixel coordinates,
some ortho-rectified pixel grid coordinates, and geophysical coordinates
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
import numpy
from sarpy.io.complex.sicd_elements.SICD import SICDType
from sarpy.geometry... | 33,381 | 36.80521 | 123 | py |
sarpy | sarpy-master/sarpy/processing/ortho_rectify/ortho_methods.py | """
Methods for ortho-rectification
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
from typing import Union
import numpy
from scipy.interpolate import RectBivariateSpline
from sarpy.io.complex.sicd_elements.SICD import SICDType
from sarpy.io.complex.base import SICDTypeRead... | 46,289 | 39.964602 | 116 | py |
sarpy | sarpy-master/sarpy/processing/sidd/sidd_product_creation.py | """
Methods for creating a variety of SIDD products.
Examples
--------
Create a variety of sidd products.
.. code-block:: python
import os
from sarpy.io.complex.converter import open_complex
from sarpy.processing.ortho_rectify import BivariateSplineMethod, NearestNeighborMethod
from sarpy.processing... | 15,252 | 39.566489 | 130 | py |
sarpy | sarpy-master/sarpy/processing/sidd/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/processing/sidd/sidd_structure_creation.py | """
Common functionality for creating the SIDD structure from a SICD structure and
OrthorectificationHelper.
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
import numpy
from sarpy.io.complex.utils import two_dim_poly_fit, get_im_physical_coords
from sarpy.processing.ortho_re... | 25,449 | 44.527728 | 119 | py |
sarpy | sarpy-master/sarpy/annotation/base.py | """
Base annotation types for general use - based on the geojson implementation
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
import os
from uuid import uuid4
from typing import Optional, Dict, List, Any, Union
import json
from collections import OrderedDict
from sarpy.geom... | 24,450 | 26.597065 | 127 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde.py | """
Simple helper functions for constructing the NGA modified AFRL/RDE structure
assuming either a known ground truth scenario or inferred analyst truth
scenario.
"""
__classification__ = 'UNCLASSIFIED'
__author__ = "Thomas McCullough"
from typing import List, Dict, Union, Optional
import numpy
from sarpy.io.comp... | 26,050 | 38.056972 | 119 | py |
sarpy | sarpy-master/sarpy/annotation/rcs.py | """
This module provides structures for annotating a given SICD type file for RCS
calculations
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
from collections import OrderedDict, defaultdict
import json
from typing import Union, Any, List
import numpy
from sarpy.geometry.ge... | 24,310 | 30.654948 | 120 | py |
sarpy | sarpy-master/sarpy/annotation/label.py | """
This module provides structures for performing data labelling on a background image
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
import logging
import time
from collections import OrderedDict
import json
from typing import Union, List, Tuple, Any, Dict, Optional
from datetime import d... | 45,023 | 30.463312 | 111 | py |
sarpy | sarpy-master/sarpy/annotation/__init__.py |
__classification__ = "UNCLASSIFIED"
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_schema/__init__.py | """
This package contains the AFRL RDE schema
"""
__classification__ = 'UNCLASSIFIED'
import pkg_resources
def get_schema_path(version='1.0.0'):
"""
Location of AFRL/RDE schema file.
Returns
-------
str
The path to the ARFL/RDE schema.
"""
if version == '1.0.0':
return ... | 524 | 20 | 88 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/SensorInfo.py | """
Definition for the SensorInfo NGA modified RDE/AFRL labeling object
"""
__classification__ = "UNCLASSIFIED"
__authors__ = "Thomas McCullough"
from typing import Optional
import numpy
from sarpy.io.xml.base import Serializable, Arrayable
from sarpy.io.xml.descriptors import SerializableDescriptor, StringDescript... | 16,613 | 38.276596 | 119 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/base.py | """
Common definition for NGA modified RDE/AFRL labeling definition
"""
__classification__ = "UNCLASSIFIED"
__author__ = "Thomas McCullough"
DEFAULT_STRICT = False
| 167 | 15.8 | 63 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/CollectionInfo.py | """
Definition for the CollectionInfo NGA modified RDE/AFRL labeling object
"""
__classification__ = "UNCLASSIFIED"
__authors__ = "Thomas McCullough"
from typing import Optional
from sarpy.io.xml.base import Serializable
from sarpy.io.xml.descriptors import IntegerDescriptor, SerializableDescriptor, \
StringDes... | 3,637 | 33.980769 | 103 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/ObjectInfo.py | """
Definition for the ObjectInfo NGA modified RDE/AFRL labeling object
"""
__classification__ = "UNCLASSIFIED"
__authors__ = "Thomas McCullough"
import logging
from typing import Optional, List
import numpy
from sarpy.io.xml.base import Serializable, Arrayable, create_text_node, \
get_node_value
from sarpy.io.... | 52,249 | 39.441176 | 135 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/ImageInfo.py | """
Definition for the ImageInfo NGA modified RDE/AFRL labeling object
"""
__classification__ = "UNCLASSIFIED"
__authors__ = "Thomas McCullough"
from typing import Optional
import numpy
from sarpy.io.xml.base import Serializable, Arrayable
from sarpy.io.xml.descriptors import StringDescriptor, SerializableDescriptor... | 21,522 | 39.456767 | 113 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/Research.py | """
Definition for the main NGA modified RDE/AFRL labeling object
"""
__classification__ = "UNCLASSIFIED"
__authors__ = "Thomas McCullough"
from typing import Optional
import os
from sarpy.io.xml.base import Serializable, parse_xml_from_string, parse_xml_from_file
from sarpy.io.xml.descriptors import SerializableDes... | 8,911 | 38.087719 | 124 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/SubCollectionInfo.py | """
Definition for the SubCollectionInfo NGA modified RDE/AFRL labeling object
"""
__classification__ = "UNCLASSIFIED"
__authors__ = "Thomas McCullough"
from typing import Optional
from sarpy.io.xml.base import Serializable
from sarpy.io.xml.descriptors import SerializableDescriptor, StringDescriptor
from .base im... | 3,552 | 40.313953 | 99 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/FiducialInfo.py | """
Definition for the FiducialInfo NGA modified RDE/AFRL labeling object
"""
__classification__ = "UNCLASSIFIED"
__authors__ = "Thomas McCullough"
from typing import Optional, List
import logging
import numpy
from sarpy.io.xml.base import Serializable
from sarpy.io.xml.descriptors import IntegerDescriptor, Seriali... | 19,093 | 38.862213 | 109 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/sarpy/annotation/afrl_rde_elements/blocks.py | """
Common use elements for the NGA modified RDE/AFRL labeling definition
"""
__classification__ = "UNCLASSIFIED"
__authors__ = "Thomas McCullough"
import numpy
from datetime import date, datetime
from typing import Optional
from sarpy.io.xml.base import Serializable, Arrayable
from sarpy.io.xml.descriptors import ... | 15,226 | 30.591286 | 106 | py |
sarpy | sarpy-master/docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
import ... | 2,007 | 36.185185 | 82 | py |
Tiny-NewsRec | Tiny-NewsRec-main/split_file.py | import random
from tqdm import tqdm
import tensorflow as tf
def get_sample(all_element, num_sample):
if num_sample > len(all_element):
return random.sample(all_element * (num_sample // len(all_element) + 1), num_sample)
else:
return random.sample(all_element, num_sample)
N = 4
behaviors = []... | 1,365 | 30.045455 | 92 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/dataloader.py | import sys
import traceback
import logging
import random
from queue import Queue
from concurrent.futures import ThreadPoolExecutor
import numpy as np
import torch
from torch.utils.data import IterableDataset
from streaming import StreamSampler
def news_sample(news, ratio):
if ratio > len(news):
return new... | 11,565 | 35.71746 | 130 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/utils.py | import logging
import os
import sys
import torch
import numpy as np
import argparse
import re
from tnlrv3.modeling import TuringNLRv3ForSequenceClassification
from tnlrv3.configuration_tnlrv3 import TuringNLRv3Config
from tnlrv3.tokenization_tnlrv3 import TuringNLRv3Tokenizer
from transformers import BertTokenizer, B... | 4,173 | 27.589041 | 94 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/run.py | import numpy as np
import torch
import logging
from tqdm.auto import tqdm
import torch.optim as optim
import utils
import os
from pathlib import Path
import random
from dataloader import DataLoaderTrain, DataLoaderTest
from torch.utils.data import Dataset, DataLoader
from streaming import get_stat, get_worker_files
imp... | 15,933 | 32.687104 | 118 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/streaming.py | import os
import logging
import fnmatch
import random
import numpy as np
import tensorflow as tf
import subprocess
def get_stat(dirname, filename_pat="*"):
if not tf.io.gfile.exists(dirname):
logging.warning(f"{dirname} does not exist!")
return None
stat = {}
for x in tf.io.gfile.listdir(... | 3,990 | 27.507143 | 129 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/parameters.py | import argparse
import utils
import logging
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--mode",
type=str,
default="train",
choices=['train', 'test', 'get_teacher_emb'])
parser.add_argument(
"--tr... | 4,778 | 37.232 | 99 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/model_bert_2.py | import numpy as np
import torch
from torch import nn
from utils import MODEL_CLASSES
class AttentionPooling(nn.Module):
def __init__(self, emb_size, hidden_size):
super(AttentionPooling, self).__init__()
self.att_fc1 = nn.Linear(emb_size, hidden_size)
self.att_fc2 = nn.Linear(hidden_size, ... | 8,043 | 36.588785 | 84 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/metrics.py | from sklearn.metrics import roc_auc_score
import numpy as np
def dcg_score(y_true, y_score, k=10):
order = np.argsort(y_score)[::-1]
y_true = np.take(y_true, order[:k])
gains = 2**y_true - 1
discounts = np.log2(np.arange(len(y_true)) + 2)
return np.sum(gains / discounts)
def ndcg_score(y_true, y... | 793 | 25.466667 | 52 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/model_bert.py | import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
from utils import MODEL_CLASSES
class AttentionPooling(nn.Module):
def __init__(self, emb_size, hidden_size):
super(AttentionPooling, self).__init__()
self.att_fc1 = nn.Linear(emb_size, hidden_size)
self.... | 12,966 | 41.375817 | 141 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/preprocess.py | import tensorflow as tf
from tqdm import tqdm
import numpy as np
from utils import MODEL_CLASSES
def update_dict(dict, key, value=None):
if key not in dict:
if value is None:
dict[key] = len(dict) + 1
else:
dict[key] = value
def read_news_bert(news_path, args, mode='train... | 2,316 | 33.58209 | 109 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/tnlrv3/convert_state_dict.py | import torch
import logging
from transformers.modeling_utils import cached_path, WEIGHTS_NAME, TF2_WEIGHTS_NAME, TF_WEIGHTS_NAME
logger = logging.getLogger(__name__)
def get_checkpoint_from_transformer_cache(
archive_file, pretrained_model_name_or_path, pretrained_model_archive_map,
cache_dir, force... | 3,162 | 40.077922 | 109 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/tnlrv3/tokenization_tnlrv3.py | # coding=utf-8
"""Tokenization classes for TuringNLRv3."""
from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import logging
import os
import unicodedata
from io import open
from transformers.tokenization_bert import BertTokenizer, whitespace_tokenize
logger = logg... | 1,646 | 31.94 | 145 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/tnlrv3/s2s_loader.py | import numpy as np
from random import randint
import logging
import torch
import torch.utils.data
logger = logging.getLogger(__name__)
def get_random_word(vocab_words):
i = randint(0, len(vocab_words)-1)
return vocab_words[i]
def batch_list_to_batch_tensors(batch):
batch_tensors = []
for x in zip... | 5,318 | 32.878981 | 90 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/tnlrv3/modeling.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import os
import torch
from torch import nn
from torch.nn.modules.loss import _Loss
import torch.nn.functional as F
from transformers.modeling_bert import \
BertPreTrainedModel, BertSelfOutput, BertInter... | 37,949 | 46.319202 | 146 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/tnlrv3/utils.py | from __future__ import absolute_import, division, print_function
import logging
import os
import json
import random
import glob
import torch
import tqdm
import array
import collections
import torch.utils.data
from transformers.file_utils import WEIGHTS_NAME
try:
import lmdb
except:
pass
OPTIM_NAME = "optimize... | 14,533 | 35.888325 | 119 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/tnlrv3/modeling_decoding.py | # coding=utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import copy
import json
import math
import logging
import numpy as np
import torch
from torch import nn
from torch.nn import CrossEntropyLoss
import torch.nn.functional as F
from tor... | 67,538 | 44.944898 | 139 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/tnlrv3/config.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
from transformers import BertConfig
from tnlrv3.configuration_tnlrv3 import TuringNLRv3Config
logger = logging.getLogger(__name__)
class TuringNLRv3ForSeq2SeqConfig(BertConfig):
def __init__(self, label_smoothing=0... | 2,104 | 41.959184 | 116 | py |
Tiny-NewsRec | Tiny-NewsRec-main/Tiny-NewsRec/tnlrv3/configuration_tnlrv3.py | # coding=utf-8
""" TuringNLRv3 model configuration """
from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import sys
from io import open
from transformers.configuration_utils import PretrainedConfig
logger = logging.getLogger(__name__)
TuringNLRv3_PRETRAIN... | 4,136 | 45.483146 | 107 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/dataloader.py | import sys
import traceback
import logging
import random
from queue import Queue
from concurrent.futures import ThreadPoolExecutor
import numpy as np
import torch
from torch.utils.data import IterableDataset
from streaming import StreamSampler
class DataLoaderTrain(IterableDataset):
def __init__(self,
... | 10,287 | 34.84669 | 92 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/utils.py | import logging
import os
import sys
import torch
import numpy as np
import argparse
import re
from tnlrv3.modeling import TuringNLRv3ForSequenceClassification
from tnlrv3.configuration_tnlrv3 import TuringNLRv3Config
from tnlrv3.tokenization_tnlrv3 import TuringNLRv3Tokenizer
from transformers import BertTokenizer, B... | 4,173 | 27.589041 | 94 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/run.py | import numpy as np
import torch
import logging
from tqdm.auto import tqdm
import torch.optim as optim
import utils
import os
from pathlib import Path
import random
from dataloader import DataLoaderTrain, DataLoaderTest
from torch.utils.data import Dataset, DataLoader
from streaming import get_stat, get_worker_files
fr... | 12,540 | 32.265252 | 97 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/streaming.py | import os
import logging
import fnmatch
import random
import numpy as np
import tensorflow as tf
import subprocess
def get_stat(dirname, filename_pat="*"):
if not tf.io.gfile.exists(dirname):
logging.warning(f"{dirname} does not exist!")
return None
stat = {}
for x in tf.io.gfile.listdir(... | 3,990 | 27.507143 | 129 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/parameters.py | import argparse
import utils
import logging
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--mode",
type=str,
default="train",
choices=['train', 'test'])
parser.add_argument(
"--train_data_dir",
... | 4,252 | 32.753968 | 83 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/metrics.py | from sklearn.metrics import roc_auc_score
import numpy as np
def dcg_score(y_true, y_score, k=10):
order = np.argsort(y_score)[::-1]
y_true = np.take(y_true, order[:k])
gains = 2**y_true - 1
discounts = np.log2(np.arange(len(y_true)) + 2)
return np.sum(gains / discounts)
def ndcg_score(y_true, y... | 793 | 25.466667 | 52 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/model_bert.py | import numpy as np
import torch
from torch import nn
from utils import MODEL_CLASSES
class AttentionPooling(nn.Module):
def __init__(self, emb_size, hidden_size):
super(AttentionPooling, self).__init__()
self.att_fc1 = nn.Linear(emb_size, hidden_size)
self.att_fc2 = nn.Linear(hidden_size,... | 8,077 | 37.836538 | 99 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/preprocess.py | import tensorflow as tf
from tqdm import tqdm
import numpy as np
from utils import MODEL_CLASSES
def update_dict(dict, key, value=None):
if key not in dict:
if value is None:
dict[key] = len(dict) + 1
else:
dict[key] = value
def read_news_bert(news_path, args, mode='train... | 2,379 | 33.492754 | 101 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/tnlrv3/convert_state_dict.py | import torch
import logging
from transformers.modeling_utils import cached_path, WEIGHTS_NAME, TF2_WEIGHTS_NAME, TF_WEIGHTS_NAME
logger = logging.getLogger(__name__)
def get_checkpoint_from_transformer_cache(
archive_file, pretrained_model_name_or_path, pretrained_model_archive_map,
cache_dir, force... | 3,162 | 40.077922 | 109 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/tnlrv3/tokenization_tnlrv3.py | # coding=utf-8
"""Tokenization classes for TuringNLRv3."""
from __future__ import absolute_import, division, print_function, unicode_literals
import collections
import logging
import os
import unicodedata
from io import open
from transformers.tokenization_bert import BertTokenizer, whitespace_tokenize
logger = logg... | 1,646 | 31.94 | 145 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/tnlrv3/s2s_loader.py | import numpy as np
from random import randint
import logging
import torch
import torch.utils.data
logger = logging.getLogger(__name__)
def get_random_word(vocab_words):
i = randint(0, len(vocab_words)-1)
return vocab_words[i]
def batch_list_to_batch_tensors(batch):
batch_tensors = []
for x in zip... | 5,318 | 32.878981 | 90 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/tnlrv3/modeling.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import os
import torch
from torch import nn
from torch.nn.modules.loss import _Loss
import torch.nn.functional as F
from transformers.modeling_bert import \
BertPreTrainedModel, BertSelfOutput, BertInter... | 38,964 | 44.360885 | 146 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/tnlrv3/utils.py | from __future__ import absolute_import, division, print_function
import logging
import os
import json
import random
import glob
import torch
import tqdm
import array
import collections
import torch.utils.data
from transformers.file_utils import WEIGHTS_NAME
try:
import lmdb
except:
pass
OPTIM_NAME = "optimize... | 14,533 | 35.888325 | 119 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/tnlrv3/modeling_decoding.py | # coding=utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import copy
import json
import math
import logging
import numpy as np
import torch
from torch import nn
from torch.nn import CrossEntropyLoss
import torch.nn.functional as F
from tor... | 67,538 | 44.944898 | 139 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/tnlrv3/config.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
from transformers import BertConfig
from tnlrv3.configuration_tnlrv3 import TuringNLRv3Config
logger = logging.getLogger(__name__)
class TuringNLRv3ForSeq2SeqConfig(BertConfig):
def __init__(self, label_smoothing=0... | 2,104 | 41.959184 | 116 | py |
Tiny-NewsRec | Tiny-NewsRec-main/PLM-NR/tnlrv3/configuration_tnlrv3.py | # coding=utf-8
""" TuringNLRv3 model configuration """
from __future__ import absolute_import, division, print_function, unicode_literals
import json
import logging
import sys
from io import open
from transformers.configuration_utils import PretrainedConfig
logger = logging.getLogger(__name__)
TuringNLRv3_PRETRAIN... | 4,136 | 45.483146 | 107 | py |
cz_corpus | cz_corpus-master/Evaluator.py | # -*- coding: utf-8 -*-
__author__ = 'svobik'
from gensim.models.word2vec import Word2Vec
from gensim import corpora, models, similarities, matutils
import re
import os
import logging
import optparse
import numpy as np
import operator
import codecs
from fnmatch import fnmatch
NUM_SEMANTIC_CLASSES = 6
logging.basicCo... | 5,830 | 34.993827 | 139 | py |
DDOD | DDOD-main/setup.py | #!/usr/bin/env python
import os
from setuptools import find_packages, setup
import torch
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
CUDAExtension)
def readme():
with open('README.md', encoding='utf-8') as f:
content = f.read()
return co... | 5,899 | 35.196319 | 125 | py |
DDOD | DDOD-main/coco_cfg/atss_r50_1x.py | fp16 = dict(loss_scale=512.)
model = dict(
type='ATSS',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch',
init_cfg... | 4,154 | 29.777778 | 99 | py |
DDOD | DDOD-main/coco_cfg/ddod_r50_1x.py | fp16 = dict(loss_scale=512.)
model = dict(
type='ATSS',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch',
init_cfg... | 4,226 | 30.080882 | 99 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.