Compare commits
28 Commits
wip/nam
...
feature/je
Author | SHA1 | Date | |
---|---|---|---|
|
9e64f00579 | ||
|
d54fc5dad1 | ||
|
c203e13604 | ||
|
4923ab8ef1 | ||
|
597a7afa67 | ||
|
7020ac587b | ||
|
872bad9b86 | ||
|
8693ecbfb6 | ||
|
6370ff61a6 | ||
|
328e789c86 | ||
|
5bc8c57490 | ||
|
75ab2897c4 | ||
|
f4519eb430 | ||
|
8ed385f6d2 | ||
|
c88bf9c6b7 | ||
|
26cc0690ef | ||
|
84f90d026d | ||
|
df99f1bc18 | ||
|
76c147b57a | ||
|
6aa8a59a57 | ||
|
2da3a8f226 | ||
|
67fff5df3c | ||
|
7d4a041df2 | ||
|
04c51c00c6 | ||
|
62185b38cf | ||
|
7b93cd4ad5 | ||
|
d7834e2cc0 | ||
|
0af8cf36f8 |
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.2.0
|
||||
current_version = 0.3.0
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
|
||||
|
5
.ci/gpu.Dockerfile
Normal file
5
.ci/gpu.Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM nvcr.io/nvidia/pytorch:21.10-py3
|
||||
|
||||
RUN adduser --uid 1000 jenkins
|
||||
|
||||
USER jenkins
|
5
.ci/python310.Dockerfile
Normal file
5
.ci/python310.Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM python:3.9
|
||||
|
||||
RUN adduser --uid 1000 jenkins
|
||||
|
||||
USER jenkins
|
5
.ci/python36.Dockerfile
Normal file
5
.ci/python36.Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM python:3.6
|
||||
|
||||
RUN adduser --uid 1000 jenkins
|
||||
|
||||
USER jenkins
|
5
.ci/python37.Dockerfile
Normal file
5
.ci/python37.Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM python:3.7
|
||||
|
||||
RUN adduser --uid 1000 jenkins
|
||||
|
||||
USER jenkins
|
5
.ci/python38.Dockerfile
Normal file
5
.ci/python38.Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM python:3.8
|
||||
|
||||
RUN adduser --uid 1000 jenkins
|
||||
|
||||
USER jenkins
|
5
.ci/python39.Dockerfile
Normal file
5
.ci/python39.Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM python:3.9
|
||||
|
||||
RUN adduser --uid 1000 jenkins
|
||||
|
||||
USER jenkins
|
25
.travis.yml
25
.travis.yml
@@ -1,25 +0,0 @@
|
||||
dist: bionic
|
||||
sudo: false
|
||||
language: python
|
||||
python: 3.9
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.cache/pip"
|
||||
- "./tests/artifacts"
|
||||
- "$HOME/datasets"
|
||||
install:
|
||||
- pip install git+git://github.com/si-cim/prototorch@dev --progress-bar off
|
||||
- pip install .[all] --progress-bar off
|
||||
script:
|
||||
- coverage run -m pytest
|
||||
- ./tests/test_examples.sh examples/
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
deploy:
|
||||
provider: pypi
|
||||
username: __token__
|
||||
password:
|
||||
secure: PDoASdYdVlt1aIROYilAsCW6XpBs/TDel0CSptDzX0CI7i4+ksEW6Jk0JyL58bQt7V4F8PeGty4A8SODzAUIk2d8sty5RI4VJjvXZFCXlUsW+JGUN3EvWNqJLnwN8TDxgu2ENao37GUh0dC6pL8b6bVDGeOLaY1E/YR1jimmTJuxxjKjBIU8ByqTNBnC3rzybMTPU3nRoOM/WMQUyReHrPoUJj685sLqrLruhAqhiYsPbotP8xY6i8+KBbhp5vgiARV2+LkbeGcYZwozCzrEqPKY7YIfVPh895cw0v4NRyFwK1P2jyyIt22Z9Ni0Uy1J5/Qp9Sv6mBPeGjm3pnpDCQyS+2bNIDaj08KUYTIo1mC/Jcu4jQgppZEF+oey9q1tgGo+/JhsTeERKV9BoPF5HDiRArU1s5aWJjFnCsHfu+W1XqX8bwN3aTYsEIaApT3/irc6XyFJIfMN82+z+lUcZ4Y1yAHT3nH1Vif+pZYZB0UOSGrHwuI/UayjKzbCzHMuHWylWB/9ehd4o4YVp6iubVHc7Sj0KQkwBgwgl6TvwNcUuFsplFabCxmX0mVcavXsWiOBc+ivPmU6574zGj0JcEk5ghVgnKH+QS96aVrKOzegwbl4O13jY8dJp+/zgXl0gJOvRKr4BhuBJKcBaMQHdSKUChVsJJtqDyt59GvWcbg=
|
||||
on:
|
||||
tags: true
|
||||
skip_existing: true
|
118
Jenkinsfile
vendored
Normal file
118
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
pipeline {
|
||||
agent none
|
||||
stages {
|
||||
stage('Unit Tests') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'python310.Dockerfile'
|
||||
dir '.ci'
|
||||
}
|
||||
|
||||
}
|
||||
steps {
|
||||
sh 'pip install pip --upgrade --progress-bar off'
|
||||
sh 'pip install .[all] --progress-bar off'
|
||||
sh '~/.local/bin/pytest -v --junitxml=reports/result.xml --cov=prototorch/ --cov-report=xml:reports/coverage.xml'
|
||||
cobertura coberturaReportFile: 'reports/coverage.xml'
|
||||
junit 'reports/**/*.xml'
|
||||
}
|
||||
}
|
||||
|
||||
stage('CPU Examples') {
|
||||
parallel {
|
||||
stage('3.10') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'python310.Dockerfile'
|
||||
dir '.ci'
|
||||
}
|
||||
|
||||
}
|
||||
steps {
|
||||
sh 'pip install pip --upgrade --progress-bar off'
|
||||
sh 'pip install .[all] --progress-bar off'
|
||||
sh './tests/test_examples.sh examples'
|
||||
}
|
||||
}
|
||||
|
||||
stage('3.9') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'python39.Dockerfile'
|
||||
dir '.ci'
|
||||
}
|
||||
|
||||
}
|
||||
steps {
|
||||
sh 'pip install pip --upgrade --progress-bar off'
|
||||
sh 'pip install .[all] --progress-bar off'
|
||||
sh './tests/test_examples.sh examples'
|
||||
}
|
||||
}
|
||||
|
||||
stage('3.8') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'python38.Dockerfile'
|
||||
dir '.ci'
|
||||
}
|
||||
|
||||
}
|
||||
steps {
|
||||
sh 'pip install pip --upgrade --progress-bar off'
|
||||
sh 'pip install .[all] --progress-bar off'
|
||||
sh './tests/test_examples.sh examples'
|
||||
}
|
||||
}
|
||||
|
||||
stage('3.7') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'python37.Dockerfile'
|
||||
dir '.ci'
|
||||
}
|
||||
|
||||
}
|
||||
steps {
|
||||
sh 'pip install pip --upgrade --progress-bar off'
|
||||
sh 'pip install .[all] --progress-bar off'
|
||||
sh './tests/test_examples.sh examples'
|
||||
}
|
||||
}
|
||||
|
||||
stage('3.6') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'python36.Dockerfile'
|
||||
dir '.ci'
|
||||
}
|
||||
|
||||
}
|
||||
steps {
|
||||
sh 'pip install pip --upgrade --progress-bar off'
|
||||
sh 'pip install .[all] --progress-bar off'
|
||||
sh './tests/test_examples.sh examples'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
stage('GPU Examples') {
|
||||
agent {
|
||||
dockerfile {
|
||||
filename 'gpu.Dockerfile'
|
||||
dir '.ci'
|
||||
args '--gpus 1'
|
||||
}
|
||||
|
||||
}
|
||||
steps {
|
||||
sh 'pip install -U pip --progress-bar off'
|
||||
sh 'pip install .[all] --progress-bar off'
|
||||
sh './tests/test_examples.sh examples --gpu'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
44
deprecated.travis.yml
Normal file
44
deprecated.travis.yml
Normal file
@@ -0,0 +1,44 @@
|
||||
dist: bionic
|
||||
sudo: false
|
||||
language: python
|
||||
python:
|
||||
- 3.9
|
||||
- 3.8
|
||||
- 3.7
|
||||
- 3.6
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.cache/pip"
|
||||
- "./tests/artifacts"
|
||||
- "$HOME/datasets"
|
||||
install:
|
||||
- pip install git+git://github.com/si-cim/prototorch@dev --progress-bar off
|
||||
- pip install .[all] --progress-bar off
|
||||
script:
|
||||
- coverage run -m pytest
|
||||
- ./tests/test_examples.sh examples/
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
# Publish on PyPI
|
||||
jobs:
|
||||
include:
|
||||
- stage: build
|
||||
python: 3.9
|
||||
script: echo "Starting Pypi build"
|
||||
deploy:
|
||||
provider: pypi
|
||||
username: __token__
|
||||
distributions: "sdist bdist_wheel"
|
||||
password:
|
||||
secure: PDoASdYdVlt1aIROYilAsCW6XpBs/TDel0CSptDzX0CI7i4+ksEW6Jk0JyL58bQt7V4F8PeGty4A8SODzAUIk2d8sty5RI4VJjvXZFCXlUsW+JGUN3EvWNqJLnwN8TDxgu2ENao37GUh0dC6pL8b6bVDGeOLaY1E/YR1jimmTJuxxjKjBIU8ByqTNBnC3rzybMTPU3nRoOM/WMQUyReHrPoUJj685sLqrLruhAqhiYsPbotP8xY6i8+KBbhp5vgiARV2+LkbeGcYZwozCzrEqPKY7YIfVPh895cw0v4NRyFwK1P2jyyIt22Z9Ni0Uy1J5/Qp9Sv6mBPeGjm3pnpDCQyS+2bNIDaj08KUYTIo1mC/Jcu4jQgppZEF+oey9q1tgGo+/JhsTeERKV9BoPF5HDiRArU1s5aWJjFnCsHfu+W1XqX8bwN3aTYsEIaApT3/irc6XyFJIfMN82+z+lUcZ4Y1yAHT3nH1Vif+pZYZB0UOSGrHwuI/UayjKzbCzHMuHWylWB/9ehd4o4YVp6iubVHc7Sj0KQkwBgwgl6TvwNcUuFsplFabCxmX0mVcavXsWiOBc+ivPmU6574zGj0JcEk5ghVgnKH+QS96aVrKOzegwbl4O13jY8dJp+/zgXl0gJOvRKr4BhuBJKcBaMQHdSKUChVsJJtqDyt59GvWcbg=
|
||||
on:
|
||||
tags: true
|
||||
skip_existing: true
|
||||
|
||||
# The password is encrypted with:
|
||||
# `cd prototorch && travis encrypt your-pypi-api-token --add deploy.password`
|
||||
# See https://docs.travis-ci.com/user/deployment/pypi and
|
||||
# https://github.com/travis-ci/travis.rb#installation
|
||||
# for more details
|
||||
# Note: The encrypt command does not work well in ZSH.
|
@@ -23,7 +23,7 @@ author = "Jensun Ravichandran"
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
#
|
||||
release = "0.2.0"
|
||||
release = "0.3.0"
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
|
@@ -1,7 +1,5 @@
|
||||
"""`models` plugin for the `prototorch` package."""
|
||||
|
||||
from importlib.metadata import PackageNotFoundError, version
|
||||
|
||||
from .callbacks import PrototypeConvergence, PruneLoserPrototypes
|
||||
from .cbc import CBC, ImageCBC
|
||||
from .glvq import (
|
||||
@@ -23,4 +21,4 @@ from .probabilistic import CELVQ, PLVQ, RSLVQ, SLVQ
|
||||
from .unsupervised import GrowingNeuralGas, HeskesSOM, KohonenSOM, NeuralGas
|
||||
from .vis import *
|
||||
|
||||
__version__ = "0.2.0"
|
||||
__version__ = "0.3.0"
|
||||
|
@@ -1,7 +1,5 @@
|
||||
"""Abstract classes to be inherited by prototorch models."""
|
||||
|
||||
from typing import Final, final
|
||||
|
||||
import pytorch_lightning as pl
|
||||
import torch
|
||||
import torchmetrics
|
||||
@@ -43,7 +41,6 @@ class ProtoTorchBolt(pl.LightningModule):
|
||||
else:
|
||||
return optimizer
|
||||
|
||||
@final
|
||||
def reconfigure_optimizers(self):
|
||||
self.trainer.accelerator.setup_optimizers(self.trainer)
|
||||
|
||||
@@ -96,7 +93,7 @@ class UnsupervisedPrototypeModel(PrototypeModel):
|
||||
)
|
||||
|
||||
def compute_distances(self, x):
|
||||
protos = self.proto_layer()
|
||||
protos = self.proto_layer().type_as(x)
|
||||
distances = self.distance_layer(x, protos)
|
||||
return distances
|
||||
|
||||
@@ -136,14 +133,14 @@ class SupervisedPrototypeModel(PrototypeModel):
|
||||
|
||||
def forward(self, x):
|
||||
distances = self.compute_distances(x)
|
||||
plabels = self.proto_layer.labels
|
||||
_, plabels = self.proto_layer()
|
||||
winning = stratified_min_pooling(distances, plabels)
|
||||
y_pred = torch.nn.functional.softmin(winning)
|
||||
return y_pred
|
||||
|
||||
def predict_from_distances(self, distances):
|
||||
with torch.no_grad():
|
||||
plabels = self.proto_layer.labels
|
||||
_, plabels = self.proto_layer()
|
||||
y_pred = self.competition_layer(distances, plabels)
|
||||
return y_pred
|
||||
|
||||
@@ -175,7 +172,7 @@ class NonGradientMixin(ProtoTorchMixin):
|
||||
"""Mixin for custom non-gradient optimization."""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.automatic_optimization: Final = False
|
||||
self.automatic_optimization = False
|
||||
|
||||
def training_step(self, train_batch, batch_idx, optimizer_idx=None):
|
||||
raise NotImplementedError
|
||||
@@ -183,7 +180,6 @@ class NonGradientMixin(ProtoTorchMixin):
|
||||
|
||||
class ImagePrototypesMixin(ProtoTorchMixin):
|
||||
"""Mixin for models with image prototypes."""
|
||||
@final
|
||||
def on_train_batch_end(self, outputs, batch, batch_idx, dataloader_idx):
|
||||
"""Constrain the components to the range [0, 1] by clamping after updates."""
|
||||
self.proto_layer.components.data.clamp_(0.0, 1.0)
|
||||
|
@@ -55,7 +55,7 @@ class PruneLoserPrototypes(pl.Callback):
|
||||
distribution = dict(zip(labels.tolist(), counts.tolist()))
|
||||
if self.verbose:
|
||||
print(f"Re-adding pruned prototypes...")
|
||||
print(f"{distribution=}")
|
||||
print(f"distribution={distribution}")
|
||||
pl_module.add_prototypes(
|
||||
distribution=distribution,
|
||||
components_initializer=self.prototypes_initializer)
|
||||
@@ -134,4 +134,4 @@ class GNGCallback(pl.Callback):
|
||||
pl_module.errors[
|
||||
worst_neighbor] = errors[worst_neighbor] * self.reduction
|
||||
|
||||
trainer.accelerator_backend.setup_optimizers(trainer)
|
||||
trainer.accelerator.setup_optimizers(trainer)
|
||||
|
@@ -55,7 +55,7 @@ class GLVQ(SupervisedPrototypeModel):
|
||||
def shared_step(self, batch, batch_idx, optimizer_idx=None):
|
||||
x, y = batch
|
||||
out = self.compute_distances(x)
|
||||
plabels = self.proto_layer.labels
|
||||
_, plabels = self.proto_layer()
|
||||
loss = self.loss(out, y, plabels)
|
||||
return out, loss
|
||||
|
||||
@@ -112,7 +112,8 @@ class SiameseGLVQ(GLVQ):
|
||||
proto_opt = self.optimizer(self.proto_layer.parameters(),
|
||||
lr=self.hparams.proto_lr)
|
||||
# Only add a backbone optimizer if backbone has trainable parameters
|
||||
if (bb_params := list(self.backbone.parameters())):
|
||||
bb_params = list(self.backbone.parameters())
|
||||
if (bb_params):
|
||||
bb_opt = self.optimizer(bb_params, lr=self.hparams.bb_lr)
|
||||
optimizers = [proto_opt, bb_opt]
|
||||
else:
|
||||
|
@@ -10,9 +10,7 @@ from .glvq import GLVQ
|
||||
class LVQ1(NonGradientMixin, GLVQ):
|
||||
"""Learning Vector Quantization 1."""
|
||||
def training_step(self, train_batch, batch_idx, optimizer_idx=None):
|
||||
protos = self.proto_layer.components
|
||||
plabels = self.proto_layer.labels
|
||||
|
||||
protos, plables = self.proto_layer()
|
||||
x, y = train_batch
|
||||
dis = self.compute_distances(x)
|
||||
# TODO Vectorized implementation
|
||||
@@ -30,8 +28,8 @@ class LVQ1(NonGradientMixin, GLVQ):
|
||||
self.proto_layer.load_state_dict({"_components": updated_protos},
|
||||
strict=False)
|
||||
|
||||
print(f"{dis=}")
|
||||
print(f"{y=}")
|
||||
print(f"dis={dis}")
|
||||
print(f"y={y}")
|
||||
# Logging
|
||||
self.log_acc(dis, y, tag="train_acc")
|
||||
|
||||
@@ -41,8 +39,7 @@ class LVQ1(NonGradientMixin, GLVQ):
|
||||
class LVQ21(NonGradientMixin, GLVQ):
|
||||
"""Learning Vector Quantization 2.1."""
|
||||
def training_step(self, train_batch, batch_idx, optimizer_idx=None):
|
||||
protos = self.proto_layer.components
|
||||
plabels = self.proto_layer.labels
|
||||
protos, plabels = self.proto_layer()
|
||||
|
||||
x, y = train_batch
|
||||
dis = self.compute_distances(x)
|
||||
@@ -99,8 +96,7 @@ class MedianLVQ(NonGradientMixin, GLVQ):
|
||||
return lower_bound
|
||||
|
||||
def training_step(self, train_batch, batch_idx, optimizer_idx=None):
|
||||
protos = self.proto_layer.components
|
||||
plabels = self.proto_layer.labels
|
||||
protos, plabels = self.proto_layer()
|
||||
|
||||
x, y = train_batch
|
||||
dis = self.compute_distances(x)
|
||||
|
@@ -20,7 +20,7 @@ class CELVQ(GLVQ):
|
||||
def shared_step(self, batch, batch_idx, optimizer_idx=None):
|
||||
x, y = batch
|
||||
out = self.compute_distances(x) # [None, num_protos]
|
||||
plabels = self.proto_layer.labels
|
||||
_, plabels = self.proto_layer()
|
||||
winning = stratified_min_pooling(out, plabels) # [None, num_classes]
|
||||
probs = -1.0 * winning
|
||||
batch_loss = self.loss(probs, y.long())
|
||||
@@ -54,7 +54,7 @@ class ProbabilisticLVQ(GLVQ):
|
||||
def training_step(self, batch, batch_idx, optimizer_idx=None):
|
||||
x, y = batch
|
||||
out = self.forward(x)
|
||||
plabels = self.proto_layer.labels
|
||||
_, plabels = self.proto_layer()
|
||||
batch_loss = self.loss(out, y, plabels)
|
||||
loss = batch_loss.sum()
|
||||
return loss
|
||||
|
@@ -53,7 +53,7 @@ class KohonenSOM(NonGradientMixin, UnsupervisedPrototypeModel):
|
||||
grid = self._grid.view(-1, 2)
|
||||
gd = squared_euclidean_distance(wp, grid)
|
||||
nh = torch.exp(-gd / self._sigma**2)
|
||||
protos = self.proto_layer.components
|
||||
protos = self.proto_layer()
|
||||
diff = x.unsqueeze(dim=1) - protos
|
||||
delta = self._lr * self.hparams.alpha * nh.unsqueeze(-1) * diff
|
||||
updated_protos = protos + delta.sum(dim=0)
|
||||
|
@@ -251,8 +251,6 @@ class VisImgComp(Vis2DAbstract):
|
||||
size=self.embedding_data,
|
||||
replace=False)
|
||||
data = self.x_train[ind]
|
||||
# print(f"{data.shape=}")
|
||||
# print(f"{self.y_train[ind].shape=}")
|
||||
tb.add_embedding(data.view(len(ind), -1),
|
||||
label_img=data,
|
||||
global_step=None,
|
||||
|
11
setup.py
11
setup.py
@@ -22,7 +22,7 @@ with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
INSTALL_REQUIRES = [
|
||||
"prototorch>=0.6.0",
|
||||
"prototorch>=0.7.0",
|
||||
"pytorch_lightning>=1.3.5",
|
||||
"torchmetrics",
|
||||
]
|
||||
@@ -46,14 +46,14 @@ EXAMPLES = [
|
||||
"scikit-learn",
|
||||
]
|
||||
TESTS = [
|
||||
"codecov",
|
||||
"pytest-cov",
|
||||
"pytest",
|
||||
]
|
||||
ALL = CLI + DEV + DOCS + EXAMPLES + TESTS
|
||||
|
||||
setup(
|
||||
name=safe_name("prototorch_" + PLUGIN_NAME),
|
||||
version="0.2.0",
|
||||
version="0.3.0",
|
||||
description="Pre-packaged prototype-based "
|
||||
"machine learning models using ProtoTorch and PyTorch-Lightning.",
|
||||
long_description=long_description,
|
||||
@@ -63,7 +63,7 @@ setup(
|
||||
url=PROJECT_URL,
|
||||
download_url=DOWNLOAD_URL,
|
||||
license="MIT",
|
||||
python_requires=">=3.9",
|
||||
python_requires=">=3.6",
|
||||
install_requires=INSTALL_REQUIRES,
|
||||
extras_require={
|
||||
"dev": DEV,
|
||||
@@ -80,6 +80,9 @@ setup(
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Natural Language :: English",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Operating System :: OS Independent",
|
||||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||||
"Topic :: Software Development :: Libraries",
|
||||
|
@@ -1,11 +1,27 @@
|
||||
#! /bin/bash
|
||||
|
||||
|
||||
# Read Flags
|
||||
gpu=0
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
--gpu) gpu=1;;
|
||||
-g) gpu=1;;
|
||||
*) path=$1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
python --version
|
||||
echo "Using GPU: " $gpu
|
||||
|
||||
# Loop
|
||||
failed=0
|
||||
|
||||
for example in $(find $1 -maxdepth 1 -name "*.py")
|
||||
for example in $(find $path -maxdepth 1 -name "*.py")
|
||||
do
|
||||
echo -n "$x" $example '... '
|
||||
export DISPLAY= && python $example --fast_dev_run 1 &> run_log.txt
|
||||
export DISPLAY= && python $example --fast_dev_run 1 --gpus $gpu &> run_log.txt
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "FAILED!!"
|
||||
cat run_log.txt
|
||||
|
Reference in New Issue
Block a user