Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for TensorFlow 2.x #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_adam.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_anchoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_linearlr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import functools
import os

import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_meanteacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_meanteacher_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_momentum.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_ra.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags
from tqdm import trange
Expand Down
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_sharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion ablation/ab_fixmatch_sharpen_conditional_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion fixmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags
from tqdm import trange
Expand Down
2 changes: 1 addition & 1 deletion fully_supervised/fs_baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import functools
import os

import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion fully_supervised/fs_mixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import os

import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion fully_supervised/lib/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import flags
from tqdm import trange

Expand Down
2 changes: 1 addition & 1 deletion ict.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import functools
import os

import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
3 changes: 1 addition & 2 deletions imagenet/augment/augment_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@

import math

import tensorflow as tf
import tensorflow.compat.v1 as tf
import tensorflow_addons as tfa


# Default replace value
REPLACE_VALUE = 128

Expand Down
3 changes: 1 addition & 2 deletions imagenet/augment/ct_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
# limitations under the License.
"""Control theory augment."""

import tensorflow as tf
import tensorflow.compat.v1 as tf

from augment import augment_ops


IMAGENET_AUG_OPS = [
'AutoContrastBlend',
'Blur',
Expand Down
2 changes: 1 addition & 1 deletion imagenet/augment/rand_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Random augment."""

import tensorflow as tf
import tensorflow.compat.v1 as tf

from augment import augment_ops

Expand Down
2 changes: 1 addition & 1 deletion imagenet/augment/weak_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Various weak agumentations."""

import tensorflow as tf
import tensorflow.compat.v1 as tf


def flip_augmentation(image):
Expand Down
7 changes: 3 additions & 4 deletions imagenet/datasets/imagenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
"""Efficient ImageNet input pipeline using tf.data.Dataset."""

import os
from absl import flags

import tensorflow as tf

import tensorflow.compat.v1 as tf
from absl import flags

IMAGENET_BUFFER_SIZE = 16 * 1024 * 1024 # 16 MiB
IMAGENET_BUFFER_SIZE = 16 * 1024 * 1024 # 16 MiB
IMAGENET_FETCH_CYCLE_LENGTH = 16
IMAGENET_SHUFFLE_BUFFER_SIZE = 1024
IMAGENET_PREPROCESSING_THREADS = 2
Expand Down
4 changes: 1 addition & 3 deletions imagenet/fixmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@
# limitations under the License.
"""Fixmatch semi-supervised training code."""

import tensorflow.compat.v1 as tf
from absl import app
from absl import flags
from absl import logging
from easydict import EasyDict

import tensorflow as tf

import training
from augment.augment import create_ssl_augmenter
from datasets import datasets
from models import resnet50_model
from utils import ema
from utils.learning_rate import ConfigurableLearningRateSchedule


FLAGS = flags.FLAGS


Expand Down
2 changes: 1 addition & 1 deletion imagenet/models/resnet50_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- http://torch.ch/blog/2016/02/04/resnets.html
"""

import tensorflow as tf
import tensorflow.compat.v1 as tf


backend = tf.keras.backend
Expand Down
7 changes: 2 additions & 5 deletions imagenet/prep_imagenet_data/save_sharded_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
import os
import time

import apache_beam as beam
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions

import tensorflow as tf


FLAGS = flags.FLAGS

flags.DEFINE_string('input_dir', None, 'Directory with input data.')
Expand Down
4 changes: 1 addition & 3 deletions imagenet/supervised.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
# limitations under the License.
"""Supervised training code."""

import tensorflow.compat.v1 as tf
from absl import app
from absl import flags
from absl import logging

import tensorflow as tf

import training
from augment.augment import create_augmenter
from datasets import datasets
from models import resnet50_model
from utils import ema
from utils.learning_rate import ConfigurableLearningRateSchedule


FLAGS = flags.FLAGS


Expand Down
4 changes: 1 addition & 3 deletions imagenet/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import os
import time

import tensorflow.compat.v1 as tf
from absl import flags
from absl import logging
from easydict import EasyDict

import tensorflow as tf


flags.DEFINE_string(
'tpu',
None,
Expand Down
2 changes: 1 addition & 1 deletion imagenet/utils/ema.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Helper functions for exponential moving average."""

import tensorflow as tf
import tensorflow.compat.v1 as tf


def assign_ema_vars_from_initial_values(ema_variables, initial_values):
Expand Down
2 changes: 1 addition & 1 deletion imagenet/utils/learning_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Utils for learning rate schedule."""

import tensorflow as tf
import tensorflow.compat.v1 as tf


class ConfigurableLearningRateSchedule(
Expand Down
2 changes: 1 addition & 1 deletion libml/augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import random

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import flags

from libml import utils, ctaugment
Expand Down
2 changes: 1 addition & 1 deletion libml/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags
from tqdm import tqdm
Expand Down
2 changes: 1 addition & 1 deletion libml/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import numbers

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf

from libml.data import DataSets

Expand Down
2 changes: 1 addition & 1 deletion libml/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import functools
import itertools

import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import flags

from libml import layers
Expand Down
2 changes: 1 addition & 1 deletion libml/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import shutil

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import flags
from tqdm import trange, tqdm

Expand Down
3 changes: 2 additions & 1 deletion libml/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import re

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import flags, logging
from tensorflow.python.client import device_lib

Expand Down Expand Up @@ -49,6 +49,7 @@ def setup_main():
def setup_tf():
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
logging.set_verbosity(logging.ERROR)
tf.disable_v2_behavior()


def smart_shape(x):
Expand Down
2 changes: 1 addition & 1 deletion mean_teacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion mixmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion mixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import functools
import os

import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion pi_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
2 changes: 1 addition & 1 deletion pseudo_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os

import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from absl import app
from absl import flags

Expand Down
Loading