diff --git a/Dockerfile b/Dockerfile index 51fefad..f84f432 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM python:3.6-slim-buster as final RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential\ gcc \ cmake \ git \ @@ -17,9 +18,12 @@ COPY requirements.txt requirements.txt COPY alpaca_client/requirements.txt alpaca_client/requirements.txt COPY alpaca_server/requirements.txt alpaca_server/requirements.txt +# increases pip timemout limit to avoid errors downloading pytorch # 1 fetch small torch - for GPU support use a runtime image from hub.docker.com/r/pytorch/pytorch # 2 install requirements for both django and model server # 3 download spacy and distilbert data +ENV PIP_DEFAULT_TIMEOUT 100 + RUN pip install --no-cache-dir \ torch==1.7.1+cpu \ -f https://download.pytorch.org/whl/torch_stable.html && \ @@ -43,8 +47,6 @@ RUN npm install --no-cache && \ npm run build - - FROM final WORKDIR /alpaca @@ -67,6 +69,7 @@ ENV ADMIN_EMAIL=admin@example.com ENV DATABASE_URL=sqlite:////db.sqlite3 ENV ALLOW_SIGNUP=False ENV DEBUG=True +ENV SECRET_KEY teste # create django admin/migrations, start alpaca-serving, start django COPY startup.sh startup.sh diff --git a/alpaca_server/alpaca_model/kerasAPI/acquisition.py b/alpaca_server/alpaca_model/kerasAPI/acquisition.py index 76b0b5d..da626b5 100644 --- a/alpaca_server/alpaca_model/kerasAPI/acquisition.py +++ b/alpaca_server/alpaca_model/kerasAPI/acquisition.py @@ -35,7 +35,8 @@ def get_mnlp(self, x_train, model, preprocess, num_tokens, batch_size=50): scores = np.array(scores) norm_scores = scores/wordslen assert len(norm_scores) == len(batch_x) - probscores.extend(list(norm_scores[wordslen.argsort()[::-1]])) + reverse_idx = wordslen.argsort()[::-1].argsort() + probscores.extend(list(norm_scores[reverse_idx])) assert len(new_datapoints) == len(probscores) probs[new_datapoints] = np.array(probscores) diff --git a/alpaca_server/alpaca_model/pytorchAPI/active_learning/acquisition.py b/alpaca_server/alpaca_model/pytorchAPI/active_learning/acquisition.py index 0bdc182..12a528d 100644 --- a/alpaca_server/alpaca_model/pytorchAPI/active_learning/acquisition.py +++ b/alpaca_server/alpaca_model/pytorchAPI/active_learning/acquisition.py @@ -62,6 +62,7 @@ def get_mnlp(self, dataset, model, num_instances, batch_size = 50): wordslen = data['wordslen'] charslen = data['charslen'] sort_info = data['sort_info'] + inverse_sort = np.asarray(sort_info).argsort() score = model.decode(words, chars, caps, wordslen, charslen, mask, usecuda = self.usecuda, score_only = True)