From 0e291fcd7a3262fc255f4d8af9cd1c1d09e9e4dd Mon Sep 17 00:00:00 2001 From: Guillaume Date: Sat, 24 Feb 2018 20:27:37 +0100 Subject: [PATCH] update nixpkgs --- .../profile_default/startup/deeproof_init.py | 25 +++++++++++------- nix/nix-shell/nix-shell-deepRoof.nix | 8 ++++-- nix/nixpkgs/custom-packages.nix | 26 +++++++++++++++++++ nix/nixpkgs/pythontoolbox.nix | 12 +++++++++ 4 files changed, 59 insertions(+), 12 deletions(-) diff --git a/dotfiles/.ipython/profile_default/startup/deeproof_init.py b/dotfiles/.ipython/profile_default/startup/deeproof_init.py index 1fa90a59..a0df6284 100644 --- a/dotfiles/.ipython/profile_default/startup/deeproof_init.py +++ b/dotfiles/.ipython/profile_default/startup/deeproof_init.py @@ -14,12 +14,12 @@ # Custom imports from deeproof.common import DATA_DIR, IMAGE_DIR, SNAPSHOT_DIR, SUBMISSION_DIR, setup_logs -from deeproof.neuro import ResNet, ShortNet +from deeproof.neuro.handcraft import ResNet, ShortNet from deeproof.dataset import RoofDataset, train_valid_split -from deeproof.train import train, snapshot +from deeproof.train import train from deeproof.validation import validate from deeproof.prediction import predict, write_submission_file -from deeproof.main import DeepRoof +from deeproof.model_handler import DeepRoofHandler log = logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s', level=logging.INFO, @@ -57,19 +57,24 @@ normalize ]) -drq = DeepRoof(run_name, logger, - ds_transform_augmented, ds_transform_raw, - sampler=None, limit_load=100) +drq = DeepRoofHandler(logger, + ds_transform_augmented, ds_transform_raw, + sampler=None, limit_load=100) -# model = ResNet50(4) -model = ShortNet((3, 64, 64)) +im, labels, labels_bin = drq.X_train[0] +y_true = labels +y_pred = torch.Tensor([[0.2, 0.1, 0.6, 0.1]]*4) + +# model = ResNet(50) +net = ShortNet((3, 64, 64)) # criterion = ConvolutedLoss() weight = torch.Tensor([1., 1.971741, 3.972452, 1.824547]) criterion = torch.nn.MultiLabelSoftMarginLoss(weight=weight) +criterion = torch.nn.CrossEntropyLoss(weight=weight) # Note, p_training has lr_decay automated -optimizer = optim.SGD(model.parameters(), lr=1e-2, momentum=0.9, +optimizer = optim.SGD(net.parameters(), lr=1e-2, momentum=0.9, weight_decay=0.0005) # Finetuning whole model -# drq.train(epochs=1, model=model, loss_func=criterion, optimizer=optimizer) +# drq.train(epochs=1, model=net, loss_func=criterion, optimizer=optimizer, record_model=False) diff --git a/nix/nix-shell/nix-shell-deepRoof.nix b/nix/nix-shell/nix-shell-deepRoof.nix index 7378017b..0e775838 100644 --- a/nix/nix-shell/nix-shell-deepRoof.nix +++ b/nix/nix-shell/nix-shell-deepRoof.nix @@ -47,17 +47,21 @@ stdenv.mkDerivation { python36Packages.scikitlearn python36Packages.xgboost - #python36Packages.pypillowfight - python36Packages.pillow-simd + python36Packages.pypillowfight + #python36Packages.pillow-simd bazel #python36Packages.tensorflow #python36Packages.tensorflowCuda #python36Packages.tensorflowWithoutCuda python36Packages.pytorch + #python36Packages.pytorchWithoutCuda #python36Packages.pytorchWithCuda python36Packages.torchvision + python36Packages.opencv # fore haze removal + python36Packages.opencv3 + python36Packages.h5py # used by keras # web: diff --git a/nix/nixpkgs/custom-packages.nix b/nix/nixpkgs/custom-packages.nix index 49973444..36b7d697 100644 --- a/nix/nixpkgs/custom-packages.nix +++ b/nix/nixpkgs/custom-packages.nix @@ -54,6 +54,32 @@ packageOverrides = super: let self = super.pkgs; in with self; rec { buildInputs = [cmake pythonPackages.scipy pythonPackages.scikitlearn]; }; + floyd-cli = pythonPackages.buildPythonPackage rec { + pname = "floyd-cli"; + version = "0.10.31"; + name = "${pname}-v${version}"; + + src = fetchFromGitHub { + owner = "floydhub"; + repo = "${pname}"; + rev = "v${version}"; + sha256 = "15ccg6jhr1skvkwd7dzx7gbv3jdczwd8qssg9h466n8m9vgq3dgg"; + }; + buildInputs = [ + pythonPackages.click + pythonPackages.clint + pythonPackages.requests + pythonPackages.requests-toolbelt + pythonPackages.marshmallow + pythonPackages.pytz + pythonPackages.tabulate + pythonPackages.pathlib2 + pythonPackages.raven + ]; + + doCheck=false; + }; + werkzeug = pythonPackages.buildPythonPackage rec { name = "werkzeug-${version}"; version = "0.12.2"; diff --git a/nix/nixpkgs/pythontoolbox.nix b/nix/nixpkgs/pythontoolbox.nix index 2a9561b1..61137217 100644 --- a/nix/nixpkgs/pythontoolbox.nix +++ b/nix/nixpkgs/pythontoolbox.nix @@ -38,6 +38,18 @@ python.buildEnv.override { # ML: pkgs.pythonPackages.pandas + + # Perso + pkgs.pythonPackages.click + pkgs.pythonPackages.clint + pkgs.pythonPackages.requests + pkgs.pythonPackages.requests-toolbelt + pkgs.pythonPackages.marshmallow + pkgs.pythonPackages.pytz + pkgs.pythonPackages.tabulate + pkgs.pythonPackages.pathlib2 + pkgs.pythonPackages.raven + floyd-cli ]; ignoreCollisions = true; }