Skip to content

Instantly share code, notes, and snippets.

View pbruneau's full-sized avatar

Pierrick Bruneau pbruneau

View GitHub Profile
@pbruneau
pbruneau / tensorflow2_keras_mnist_runner.py
Last active November 26, 2020 08:50
Adaptation of tensorflow2_keras_mnist in order to train an ensemble with repeated horovod.run() calls
# Copyright 2019 Uber Technologies, Inc. All Rights Reserved.
#
# 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 applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@pbruneau
pbruneau / benchmark_m4_sample.py
Created April 19, 2021 06:35
benchmark_m4 simplified sample
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
@pbruneau
pbruneau / DeepAREstimator_Sample.py
Last active June 24, 2021 06:10
DeepAREstimator Sample
import numpy as np
import pandas as pd
# uncomment to deactivate progress bar
#from gluonts.env import env
#env._push(use_tqdm=False)
from gluonts.dataset.common import ListDataset
from gluonts.dataset.field_names import FieldName
from gluonts.model.deepar import DeepAREstimator
@pbruneau
pbruneau / cudf_multiindex.py
Created June 22, 2021 14:44
cudf with pandas MultiIndex
from datetime import datetime
import pandas as pd
import cudf
import numpy as np
start = pd.Timestamp(datetime.strptime('2021-03-12 00:00+0000', '%Y-%m-%d %H:%M%z'))
end = pd.Timestamp(datetime.strptime('2021-03-12 11:00+0000', '%Y-%m-%d %H:%M%z'))
timestamps = pd.date_range(start, end, freq='1H')
value = np.random.normal(size=12)
df = pd.DataFrame(value, index=timestamps, columns=['value'])
@pbruneau
pbruneau / keras_pipeline_trial.py
Created September 8, 2021 08:21
Trial of a DALIDataset with external input for Keras
import glob
import numpy as np
import cupy as cp
import imageio
from random import shuffle
from nvidia.dali import Pipeline
import nvidia.dali.fn as fn
import nvidia.dali.plugin.tf as dali_tf
import tensorflow as tf
@pbruneau
pbruneau / keras_pipeline_trial_fixed.py
Created September 8, 2021 12:48
Trial of a DALIDataset with external input for Keras
import glob
import numpy as np
import cupy as cp
import imageio
from random import shuffle
from nvidia.dali import Pipeline
import nvidia.dali.fn as fn
import nvidia.dali.plugin.tf as dali_tf
import tensorflow as tf
@pbruneau
pbruneau / keras_pipeline_trial_withlabels.py
Created September 8, 2021 15:55
Trial of a DALIDataset with external input for Keras
import glob
import numpy as np
import cupy as cp
import imageio
from random import shuffle
from nvidia.dali import Pipeline
import nvidia.dali.fn as fn
import nvidia.dali.plugin.tf as dali_tf
import tensorflow as tf
@pbruneau
pbruneau / create_predictor_error.py
Created September 22, 2021 14:34
Code triggering Estimator.create_predictor error
from gluonts.dataset.repository.datasets import get_dataset
from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
from gluonts.model.deepar import DeepAREstimator
from gluonts.mx.distribution.gaussian import GaussianOutput
from gluonts.mx import Trainer
from gluonts.mx.trainer.callback import TrainingHistory
from gluonts.evaluation import Evaluator
from gluonts.dataset.common import Dataset
from gluonts.mx import copy_parameters
from gluonts.model.predictor import Predictor
@pbruneau
pbruneau / code_predictor_fixed.py
Created September 23, 2021 10:34
Fixing Estimator.create_predictor error
from gluonts.dataset.repository.datasets import get_dataset
from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
from gluonts.model.deepar import DeepAREstimator
from gluonts.mx.distribution.gaussian import GaussianOutput
from gluonts.mx import Trainer
from gluonts.mx.trainer.callback import TrainingHistory
from gluonts.evaluation import Evaluator
from gluonts.dataset.common import Dataset
from gluonts.mx import copy_parameters
from gluonts.model.predictor import Predictor
@pbruneau
pbruneau / cudf_multiindex_updated.py
Last active November 2, 2021 13:49
cudf with pandas MultiIndex
from datetime import datetime
import pandas as pd
import cudf
import numpy as np
start = pd.Timestamp(datetime.strptime('2021-03-12 00:00+0000', '%Y-%m-%d %H:%M%z'))
end = pd.Timestamp(datetime.strptime('2021-03-12 11:00+0000', '%Y-%m-%d %H:%M%z'))
timestamps = pd.date_range(start, end, freq='1H')
value = np.random.normal(size=12)
df = pd.DataFrame(value, index=timestamps, columns=['value'])