repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
DiffPure | DiffPure-master/score_sde/models/layers.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 22,687 | 33.271903 | 112 | py |
DiffPure | DiffPure-master/score_sde/models/ddpm.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 6,082 | 32.423077 | 113 | py |
DiffPure | DiffPure-master/score_sde/models/ncsnv2.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 16,043 | 37.567308 | 120 | py |
DiffPure | DiffPure-master/score_sde/models/normalization.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 7,657 | 34.453704 | 106 | py |
DiffPure | DiffPure-master/score_sde/models/ema.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/yang-song/score_sde_pytorch/blob/main/models/ema.py
#
# The license for the original version of this file can be
# found in the `score_sde` directory (LICENSE_SCORE_SDE).
# ----------------... | 3,783 | 34.698113 | 119 | py |
DiffPure | DiffPure-master/score_sde/models/ncsnpp.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 13,653 | 34.743455 | 113 | py |
DiffPure | DiffPure-master/score_sde/models/layerspp.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 9,001 | 31.734545 | 99 | py |
DiffPure | DiffPure-master/score_sde/op/upfirdn2d.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/yang-song/score_sde_pytorch/blob/main/op/upfirdn2d.py
#
# The license for the original version of this file can be
# found in the `score_sde` directory (LICENSE_SCORE_SDE).
# --------------... | 6,043 | 27.91866 | 108 | py |
DiffPure | DiffPure-master/score_sde/op/__init__.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/yang-song/score_sde_pytorch/blob/main/op/__init__.py
#
# The license for the original version of this file can be
# found in the `score_sde` directory (LICENSE_SCORE_SDE).
# ---------------... | 459 | 40.818182 | 73 | py |
DiffPure | DiffPure-master/score_sde/op/fused_act.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/yang-song/score_sde_pytorch/blob/main/op/fused_act.py
#
# The license for the original version of this file can be
# found in the `score_sde` directory (LICENSE_SCORE_SDE).
# --------------... | 3,061 | 27.886792 | 83 | py |
DiffPure | DiffPure-master/runners/diffpure_guided.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 3,551 | 38.466667 | 105 | py |
DiffPure | DiffPure-master/runners/diffpure_ode.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 9,933 | 38.736 | 131 | py |
DiffPure | DiffPure-master/runners/diffpure_ldsde.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 10,418 | 40.181818 | 115 | py |
DiffPure | DiffPure-master/runners/diffpure_ddpm.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 5,358 | 36.475524 | 113 | py |
DiffPure | DiffPure-master/runners/diffpure_sde.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 10,334 | 40.673387 | 115 | py |
DiffPure | DiffPure-master/bpda_eot/bpda_eot_attack.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This file has been modified from ebm-defense.
#
# Source:
# https://github.com/point0bar1/ebm-defense/blob/master/bpda_eot_attack.py
#
# The license for the original version of this file ... | 8,620 | 45.349462 | 135 | py |
DiffPure | DiffPure-master/guided_diffusion/resample.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/resample.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# ---------... | 6,065 | 36.214724 | 87 | py |
DiffPure | DiffPure-master/guided_diffusion/losses.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/losses.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# -----------... | 2,908 | 32.825581 | 109 | py |
DiffPure | DiffPure-master/guided_diffusion/image_datasets.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/image_datasets.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# ---... | 6,312 | 34.869318 | 89 | py |
DiffPure | DiffPure-master/guided_diffusion/nn.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/nn.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# ---------------... | 5,390 | 29.117318 | 88 | py |
DiffPure | DiffPure-master/guided_diffusion/fp16_util.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/fp16_util.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# --------... | 8,318 | 32.955102 | 114 | py |
DiffPure | DiffPure-master/guided_diffusion/unet.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/unet.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# -------------... | 31,605 | 34.001107 | 124 | py |
DiffPure | DiffPure-master/guided_diffusion/gaussian_diffusion.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/gaussian_diffusion.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
#... | 34,721 | 36.864776 | 129 | py |
DiffPure | DiffPure-master/guided_diffusion/train_util.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/train_util.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# -------... | 10,982 | 34.429032 | 88 | py |
DiffPure | DiffPure-master/guided_diffusion/respace.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/respace.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# ----------... | 5,568 | 39.649635 | 85 | py |
DiffPure | DiffPure-master/guided_diffusion/dist_util.py | # ---------------------------------------------------------------
# Taken from the following link as is from:
# https://github.com/openai/guided-diffusion/blob/main/guided_diffusion/dist_util.py
#
# The license for the original version of this file can be
# found in this directory (LICENSE_GUIDED_DIFFUSION).
# --------... | 2,801 | 26.470588 | 87 | py |
DiffPure | DiffPure-master/classifiers/cifar10_resnet.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 7,977 | 38.89 | 116 | py |
DiffPure | DiffPure-master/classifiers/attribute_classifier.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 2,276 | 33.5 | 104 | py |
DiffPure | DiffPure-master/classifiers/attribute_net.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 8,507 | 36.315789 | 91 | py |
DiffPure | DiffPure-master/data/datasets.py | # ---------------------------------------------------------------
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the NVIDIA Source Code License
# for DiffPure. To view a copy of this license, see the LICENSE file.
# --------------------------------------------------------... | 13,203 | 38.181009 | 120 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_unbias/pretrain/dataset.py | # -*- coding: utf-8 -*-
import sys,os
import random
import collections
from models.utils import SPECIAL_TOKENS
import logging
import numpy as np
import torch
from torch.utils.data import Dataset, IterableDataset
from dataclasses import dataclass
from typing import List, Dict, Any
logger = logging.getLogger(__name__)... | 15,976 | 41.155673 | 143 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_unbias/pretrain/trainer.py | # -*- coding: utf-8 -*-
import os
from typing import Dict, List, Tuple, Optional, Any, Union
import torch
from transformers.trainer import Trainer
from transformers.trainer_pt_utils import nested_detach
import logging
logger = logging.getLogger(__name__)
class Pretrainer(Trainer):
def compute_loss(self, model, i... | 3,918 | 36.32381 | 109 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_unbias/models/modeling.py | # -*- coding: utf-8 -*-
import torch
from torch import nn
import torch.distributed as dist
import torch.nn.functional as F
from transformers import BertModel, BertPreTrainedModel
from torch.nn import CrossEntropyLoss
import logging
logger = logging.getLogger(__name__)
from transformers.activations import ACT2FN
fro... | 7,146 | 42.054217 | 116 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_unbias/models/debias_model.py | # -*- coding: utf-8 -*-
import torch
from torch import nn
from torch.nn import BatchNorm1d
class DenoisingNetMultiFeature(nn.Module):
def __init__(self, fea_name, emb_size, num_candidates, per_device_train_batch_size, train_group_size, fea_d, fea_c):
super(DenoisingNetMultiFeature, self).__init__()
... | 2,884 | 44.078125 | 120 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/paddle_pretrain/convert/convert-onnx.py | # -*- coding: utf-8 -*-
# @Time : 2023/1/3 23:32
# @Author : Xiangsheng Li
# @File : convert-onnx.py
import sys
import numpy as np
sys.path.append('../../pytorch_pretrain')
from transformers import AutoConfig
from models.modeling import CTRPretrainingModel
input_names = ["input_ids","attention_mask","token_type_ids"... | 1,335 | 40.75 | 138 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/paddle_pretrain/finetune/dataset.py | # -*- coding: utf-8 -*-
# @Time : 2022/12/28 23:20
# @Author : Xiangsheng Li
# @File : dataset.py
import sys,os
import random
import collections
from models.utils import SPECIAL_TOKENS
import logging
import numpy as np
import paddle
from paddle.io import Dataset, IterableDataset
from dataclasses import dataclass
fro... | 3,711 | 35.038835 | 136 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/paddle_pretrain/finetune/trainer.py | # -*- coding: utf-8 -*-
# @Time : 2022/12/28 23:27
# @Author : Xiangsheng Li
# @File : trainer.py
import os
from typing import Dict, List, Tuple, Optional, Any, Union
'''
import torch
from torch.utils.data import DataLoader
from torch.nn import Softmax, MarginRankingLoss
'''
import paddle
from paddle.io import Data... | 1,876 | 26.202899 | 86 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/paddle_pretrain/models/modeling.py | # -*- coding: utf-8 -*-
# @Time : 2022/10/25 12:02
# @Author : Xiangsheng Li
# @File : modeling.py
import paddle
import paddle.nn as nn
import paddle.nn.functional as F
from paddle.nn import Layer
from paddlenlp.transformers import (
BertPretrainedModel as BertPreTrainedModel,
BertModel,
ACT2FN
)
from pa... | 4,428 | 36.218487 | 118 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_pretrain/mt_pretrain/dataset.py | # -*- coding: utf-8 -*-
# @Time : 2022/10/25 21:07
# @Author : Xiangsheng Li
# @File : dataset.py
import sys,os
import random
import collections
from models.utils import SPECIAL_TOKENS
import logging
import numpy as np
import torch
from torch.utils.data import Dataset,IterableDataset
from dataclasses import dataclas... | 15,597 | 39.201031 | 161 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_pretrain/mt_pretrain/trainer.py | # -*- coding: utf-8 -*-
# @Time : 2022/10/26 16:51
# @Author : Xiangsheng Li
# @File : trainer.py
import os
from typing import Dict, List, Tuple, Optional, Any, Union
import torch
import torch.distributed as dist
from torch import nn, Tensor
from torch.cuda.amp import autocast
import torch.nn.functional as F
from tr... | 4,701 | 37.540984 | 109 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_pretrain/pretrain/dataset.py | # -*- coding: utf-8 -*-
# @Time : 2022/10/25 21:07
# @Author : Xiangsheng Li
# @File : dataset.py
import sys,os
import random
import collections
from models.utils import SPECIAL_TOKENS
import logging
import numpy as np
import torch
from torch.utils.data import Dataset,IterableDataset
from dataclasses import dataclas... | 13,414 | 39.044776 | 160 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_pretrain/pretrain/trainer.py | # -*- coding: utf-8 -*-
# @Time : 2022/10/26 16:51
# @Author : Xiangsheng Li
# @File : trainer.py
import os
from typing import Dict, List, Tuple, Optional, Any, Union
import torch
import torch.distributed as dist
from torch import nn, Tensor
from torch.cuda.amp import autocast
import torch.nn.functional as F
from tr... | 4,014 | 37.605769 | 109 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_pretrain/finetune/dataset.py | # -*- coding: utf-8 -*-
# @Time : 2022/11/1 16:22
# @Author : Xiangsheng Li
# @File : dataset.py
import sys,os
import random
import collections
from models.utils import SPECIAL_TOKENS
import logging
import numpy as np
import torch
from torch.utils.data import Dataset, IterableDataset
from dataclasses import dataclass... | 3,483 | 34.191919 | 111 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_pretrain/finetune/trainer.py | # -*- coding: utf-8 -*-
# @Time : 2022/11/2 14:38
# @Author : Xiangsheng Li
# @File : trainer.py
import os
from typing import Dict, List, Tuple, Optional, Any, Union
import torch
from torch import nn, Tensor
import torch.nn.functional as F
from torch.utils.data import DataLoader
from torch.nn import Softmax, Margin... | 1,976 | 28.954545 | 86 | py |
Tencent_wsdm_cup2023 | Tencent_wsdm_cup2023-main/pytorch_pretrain/models/modeling.py | # -*- coding: utf-8 -*-
# @Time : 2022/10/25 12:02
# @Author : Xiangsheng Li
# @File : modeling.py
import torch
from torch import nn, Tensor
import torch.distributed as dist
import torch.nn.functional as F
from transformers import BertModel, BertPreTrainedModel
from transformers.modeling_outputs import MaskedLMOutpu... | 5,193 | 37.474074 | 116 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_TSP/TORCH_OBJECTS.py |
"""
The MIT License
Copyright (c) Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... | 1,570 | 32.425532 | 77 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_TSP/source/utilities.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 5,647 | 26.686275 | 106 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_TSP/source/travelling_saleman_problem.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 7,808 | 30.873469 | 112 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_TSP/source/MODEL__Actor/grouped_actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 11,175 | 34.592357 | 107 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_TSP/source/TRAIN_N_EVAL/Train_Grouped_Actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 4,697 | 36.584 | 122 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_TSP/source/TRAIN_N_EVAL/Evaluate_Grouped_Actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 3,672 | 34.317308 | 123 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_KP/TORCH_OBJECTS.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 1,573 | 32.489362 | 77 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_KP/source/utilities.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 4,907 | 27.045714 | 106 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_KP/source/knapsack_problem.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 10,073 | 33.033784 | 118 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_KP/source/MODEL__Actor/grouped_actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 10,279 | 32.594771 | 102 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_KP/source/TRAIN_N_EVAL/Train_Grouped_Actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 5,058 | 36.753731 | 128 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_KP/source/TRAIN_N_EVAL/Evaluate_Grouped_Actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 3,710 | 36.11 | 112 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_CVRP/TORCH_OBJECTS.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 1,575 | 32.531915 | 77 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_CVRP/source/cvrp.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 12,715 | 35.645533 | 119 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_CVRP/source/utilities.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 5,645 | 26.950495 | 106 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_CVRP/source/MODEL__Actor/grouped_actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 10,612 | 33.016026 | 112 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_CVRP/source/TRAIN_N_EVAL/Evaluate__Grouped_Actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 3,969 | 36.45283 | 94 | py |
POMO | POMO-master/OLD_ipynb_ver/POMO_CVRP/source/TRAIN_N_EVAL/Train_Grouped_Actors.py |
"""
The MIT License
Copyright (c) 2020 Yeong-Dae Kwon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, pu... | 5,310 | 37.485507 | 109 | py |
POMO | POMO-master/NEW_py_ver/CVRP/CVRProblemDef.py |
import torch
import numpy as np
def get_random_problems(batch_size, problem_size):
depot_xy = torch.rand(size=(batch_size, 1, 2))
# shape: (batch, 1, 2)
node_xy = torch.rand(size=(batch_size, problem_size, 2))
# shape: (batch, problem, 2)
if problem_size == 20:
demand_scaler = 30
e... | 1,263 | 25.333333 | 94 | py |
POMO | POMO-master/NEW_py_ver/CVRP/POMO/CVRPEnv.py |
from dataclasses import dataclass
import torch
from CVRProblemDef import get_random_problems, augment_xy_data_by_8_fold
@dataclass
class Reset_State:
depot_xy: torch.Tensor = None
# shape: (batch, 1, 2)
node_xy: torch.Tensor = None
# shape: (batch, problem, 2)
node_demand: torch.Tensor = None
... | 8,799 | 35.514523 | 125 | py |
POMO | POMO-master/NEW_py_ver/CVRP/POMO/CVRPModel.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
class CVRPModel(nn.Module):
def __init__(self, **model_params):
super().__init__()
self.model_params = model_params
self.encoder = CVRP_Encoder(**model_params)
self.decoder = CVRP_Decoder(**model_params)
... | 14,042 | 36.150794 | 109 | py |
POMO | POMO-master/NEW_py_ver/CVRP/POMO/CVRPTrainer.py |
import torch
from logging import getLogger
from CVRPEnv import CVRPEnv as Env
from CVRPModel import CVRPModel as Model
from torch.optim import Adam as Optimizer
from torch.optim.lr_scheduler import MultiStepLR as Scheduler
from utils.utils import *
class CVRPTrainer:
def __init__(self,
env_pa... | 8,460 | 41.094527 | 120 | py |
POMO | POMO-master/NEW_py_ver/CVRP/POMO/CVRPTester.py |
import torch
import os
from logging import getLogger
from CVRPEnv import CVRPEnv as Env
from CVRPModel import CVRPModel as Model
from utils.utils import *
class CVRPTester:
def __init__(self,
env_params,
model_params,
tester_params):
# save arguments... | 4,557 | 33.793893 | 115 | py |
POMO | POMO-master/NEW_py_ver/TSP/TSProblemDef.py |
import torch
import numpy as np
def get_random_problems(batch_size, problem_size):
problems = torch.rand(size=(batch_size, problem_size, 2))
# problems.shape: (batch, problem, 2)
return problems
def augment_xy_data_by_8_fold(problems):
# problems.shape: (batch, problem, 2)
x = problems[:, :, [... | 856 | 26.645161 | 85 | py |
POMO | POMO-master/NEW_py_ver/TSP/POMO/TSPEnv.py |
from dataclasses import dataclass
import torch
from TSProblemDef import get_random_problems, augment_xy_data_by_8_fold
@dataclass
class Reset_State:
problems: torch.Tensor
# shape: (batch, problem, 2)
@dataclass
class Step_State:
BATCH_IDX: torch.Tensor
POMO_IDX: torch.Tensor
# shape: (batch, ... | 4,228 | 32.039063 | 113 | py |
POMO | POMO-master/NEW_py_ver/TSP/POMO/TSPModel.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
class TSPModel(nn.Module):
def __init__(self, **model_params):
super().__init__()
self.model_params = model_params
self.encoder = TSP_Encoder(**model_params)
self.decoder = TSP_Decoder(**model_params)
sel... | 11,293 | 34.074534 | 109 | py |
POMO | POMO-master/NEW_py_ver/TSP/POMO/TSPTester.py |
import torch
import os
from logging import getLogger
from TSPEnv import TSPEnv as Env
from TSPModel import TSPModel as Model
from utils.utils import *
class TSPTester:
def __init__(self,
env_params,
model_params,
tester_params):
# save arguments
... | 4,389 | 33.296875 | 115 | py |
POMO | POMO-master/NEW_py_ver/TSP/POMO/TSPTrainer.py |
import torch
from logging import getLogger
from TSPEnv import TSPEnv as Env
from TSPModel import TSPModel as Model
from torch.optim import Adam as Optimizer
from torch.optim.lr_scheduler import MultiStepLR as Scheduler
from utils.utils import *
class TSPTrainer:
def __init__(self,
env_params,... | 8,357 | 41.642857 | 120 | py |
exoplanet-atlas | exoplanet-atlas-main/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# exoplanet-atlas documentation build configuration file, created by
# sphinx-quickstart on Sun Nov 17 17:31:38 2019.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in t... | 5,305 | 29.147727 | 83 | py |
animeGAN | animeGAN-master/main.py | from __future__ import print_function
import os
import time
import random
import argparse
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
import torch.utils.data
import torchvision.datasets as dset
import torchvision.transforms as transforms
i... | 8,259 | 37.418605 | 124 | py |
animeGAN | animeGAN-master/models.py | import torch
import torch.nn as nn
import torch.nn.parallel
def weights_init(m):
classname = m.__class__.__name__
if classname.find('Conv') != -1:
m.weight.data.normal_(0.0, 0.02)
elif classname.find('BatchNorm') != -1:
m.weight.data.normal_(1.0, 0.02)
m.bias.data.fill_(0)
# DCGA... | 9,855 | 37.20155 | 89 | py |
bnp | bnp-master/bayesian_optimization/run_bo.py | import os
import argparse
from attrdict import AttrDict
import numpy as np
import os.path as osp
import yaml
import torch
from data.gp import *
import bayeso
import bayeso.gp as bayesogp
from bayeso import covariance
from bayeso import acquisition
from utils.paths import results_path
from utils.misc import load_mod... | 10,873 | 32.875389 | 138 | py |
bnp | bnp-master/bayesian_optimization/models/anp.py | import torch
import torch.nn as nn
from torch.distributions import kl_divergence
from attrdict import AttrDict
from utils.misc import stack, logmeanexp
from utils.sampling import sample_subset
from models.modules import CrossAttnEncoder, PoolingEncoder, Decoder
class ANP(nn.Module):
def __init__(self,
... | 3,447 | 32.153846 | 83 | py |
bnp | bnp-master/bayesian_optimization/models/cnp.py | import torch
import torch.nn as nn
from attrdict import AttrDict
from models.modules import PoolingEncoder, Decoder
class CNP(nn.Module):
def __init__(self,
dim_x=1,
dim_y=1,
dim_hid=128,
enc_pre_depth=4,
enc_post_depth=2,
dec_depth=3):
... | 1,748 | 27.672131 | 71 | py |
bnp | bnp-master/bayesian_optimization/models/modules.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
from models.attention import MultiHeadAttn, SelfAttn
__all__ = ['PoolingEncoder', 'CrossAttnEncoder', 'Decoder']
def build_mlp(dim_in, dim_hid, dim_out, depth):
modules = [nn.Linear(dim_in, dim_hid), nn.ReLU... | 3,867 | 33.535714 | 78 | py |
bnp | bnp-master/bayesian_optimization/models/banp.py | import torch
import torch.nn as nn
from attrdict import AttrDict
from models.canp import CANP
from utils.misc import stack, logmeanexp
from utils.sampling import sample_with_replacement as SWR, sample_subset
class BANP(CANP):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
s... | 2,555 | 31.35443 | 72 | py |
bnp | bnp-master/bayesian_optimization/models/canp.py | import torch
import torch.nn as nn
from attrdict import AttrDict
from models.modules import CrossAttnEncoder, Decoder, PoolingEncoder
class CANP(nn.Module):
def __init__(self,
dim_x=1,
dim_y=1,
dim_hid=128,
enc_v_depth=4,
enc_qk_depth=2,
enc_... | 1,886 | 27.590909 | 68 | py |
bnp | bnp-master/bayesian_optimization/models/bnp.py | import torch
import torch.nn as nn
from attrdict import AttrDict
from models.cnp import CNP
from utils.misc import stack, logmeanexp
from utils.sampling import sample_with_replacement as SWR, sample_subset
class BNP(CNP):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.... | 2,527 | 31.410256 | 72 | py |
bnp | bnp-master/bayesian_optimization/models/np.py | import torch
import torch.nn as nn
from torch.distributions import kl_divergence
from attrdict import AttrDict
from utils.misc import stack, logmeanexp
from utils.sampling import sample_subset
from models.modules import PoolingEncoder, Decoder
class NP(nn.Module):
def __init__(self,
dim_x=1,
... | 3,352 | 33.214286 | 83 | py |
bnp | bnp-master/bayesian_optimization/models/attention.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class MultiHeadAttn(nn.Module):
def __init__(self, dim_q, dim_k, dim_v, dim_out, num_heads=8):
super().__init__()
self.num_heads = num_heads
self.dim_out = dim_out
self.fc_q = nn.Linear(dim_q, dim_out, bi... | 1,805 | 35.857143 | 76 | py |
bnp | bnp-master/bayesian_optimization/utils/misc.py | import os
from importlib.machinery import SourceFileLoader
import math
import torch
def gen_load_func(parser, func):
def load(args, cmdline):
sub_args, cmdline = parser.parse_known_args(cmdline)
for k, v in sub_args.__dict__.items():
args.__dict__[k] = v
return func(**sub_args._... | 726 | 29.291667 | 65 | py |
bnp | bnp-master/bayesian_optimization/utils/log.py | import torch
import time
import logging
from collections import OrderedDict
def get_logger(filename, mode='a'):
logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger()
logger.addHandler(logging.FileHandler(filename, mode=mode))
return logger
class RunningAverage(obje... | 1,679 | 27 | 65 | py |
bnp | bnp-master/bayesian_optimization/utils/sampling.py | import torch
def gather(items, idxs):
K = idxs.shape[0]
idxs = idxs.to(items[0].device)
gathered = []
for item in items:
gathered.append(torch.gather(
torch.stack([item]*K), -2,
torch.stack([idxs]*item.shape[-1], -1)).squeeze(0))
return gathered[0] if len(gathered) =... | 1,334 | 32.375 | 73 | py |
bnp | bnp-master/bayesian_optimization/data/gp.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import MultivariateNormal, StudentT
from attrdict import AttrDict
import math
__all__ = ['GPPriorSampler', 'GPSampler', 'RBFKernel', 'PeriodicKernel', 'Matern52Kernel']
class GPPriorSampler(object):
def __init__(self, kern... | 4,576 | 34.207692 | 90 | py |
bnp | bnp-master/regression/gp.py | import os
import os.path as osp
import argparse
import yaml
import torch
import torch.nn as nn
import math
import time
import matplotlib.pyplot as plt
from attrdict import AttrDict
from tqdm import tqdm
from copy import deepcopy
from data.gp import *
from utils.misc import load_module, logmeanexp
from utils.paths ... | 13,075 | 32.875648 | 92 | py |
bnp | bnp-master/regression/emnist.py | import os
import os.path as osp
import argparse
import yaml
import torch
import torch.nn as nn
import math
import time
import matplotlib.pyplot as plt
from attrdict import AttrDict
from tqdm import tqdm
from copy import deepcopy
from data.image import img_to_task, task_to_img
from data.emnist import EMNIST
from ut... | 9,732 | 31.335548 | 96 | py |
bnp | bnp-master/regression/lotka_volterra.py | import os
import os.path as osp
import argparse
import yaml
import torch
import torch.nn as nn
import math
import time
import matplotlib.pyplot as plt
from attrdict import AttrDict
from tqdm import tqdm
from copy import deepcopy
from utils.misc import load_module, logmeanexp
from utils.paths import results_path, da... | 10,852 | 32.291411 | 104 | py |
bnp | bnp-master/regression/celeba.py | import os
import os.path as osp
import argparse
import yaml
import torch
import torch.nn as nn
import math
import time
import matplotlib.pyplot as plt
from attrdict import AttrDict
from tqdm import tqdm
from copy import deepcopy
from data.image import img_to_task, task_to_img
from data.celeba import CelebA
from ut... | 9,536 | 31.328814 | 96 | py |
bnp | bnp-master/regression/models/anp.py | import torch
import torch.nn as nn
from torch.distributions import kl_divergence
from attrdict import AttrDict
from utils.misc import stack, logmeanexp
from utils.sampling import sample_subset
from models.modules import CrossAttnEncoder, PoolingEncoder, Decoder
class ANP(nn.Module):
def __init__(self,
... | 3,447 | 32.153846 | 83 | py |
bnp | bnp-master/regression/models/cnp.py | import torch
import torch.nn as nn
from attrdict import AttrDict
from models.modules import PoolingEncoder, Decoder
class CNP(nn.Module):
def __init__(self,
dim_x=1,
dim_y=1,
dim_hid=128,
enc_pre_depth=4,
enc_post_depth=2,
dec_depth=3):
... | 1,748 | 27.672131 | 71 | py |
bnp | bnp-master/regression/models/modules.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Normal
from models.attention import MultiHeadAttn, SelfAttn
__all__ = ['PoolingEncoder', 'CrossAttnEncoder', 'Decoder']
def build_mlp(dim_in, dim_hid, dim_out, depth):
modules = [nn.Linear(dim_in, dim_hid), nn.ReLU... | 3,867 | 33.535714 | 78 | py |
bnp | bnp-master/regression/models/banp.py | import torch
import torch.nn as nn
from attrdict import AttrDict
from models.canp import CANP
from utils.misc import stack, logmeanexp
from utils.sampling import sample_with_replacement as SWR, sample_subset
class BANP(CANP):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
s... | 2,555 | 31.35443 | 72 | py |
bnp | bnp-master/regression/models/canp.py | import torch
import torch.nn as nn
from attrdict import AttrDict
from models.modules import CrossAttnEncoder, Decoder, PoolingEncoder
class CANP(nn.Module):
def __init__(self,
dim_x=1,
dim_y=1,
dim_hid=128,
enc_v_depth=4,
enc_qk_depth=2,
enc_... | 1,886 | 27.590909 | 68 | py |
bnp | bnp-master/regression/models/bnp.py | import torch
import torch.nn as nn
from attrdict import AttrDict
from models.cnp import CNP
from utils.misc import stack, logmeanexp
from utils.sampling import sample_with_replacement as SWR, sample_subset
class BNP(CNP):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.... | 2,527 | 31.410256 | 72 | py |
bnp | bnp-master/regression/models/np.py | import torch
import torch.nn as nn
from torch.distributions import kl_divergence
from attrdict import AttrDict
from utils.misc import stack, logmeanexp
from utils.sampling import sample_subset
from models.modules import PoolingEncoder, Decoder
class NP(nn.Module):
def __init__(self,
dim_x=1,
... | 3,352 | 33.214286 | 83 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.