Code Monkey home page Code Monkey logo

Comments (6)

wjchicago avatar wjchicago commented on July 20, 2024

Sorry just found it is in the environment.yml already.

My python version is 3.7.3. Maybe it is too high for this.

from finbert.

wjchicago avatar wjchicago commented on July 20, 2024

Seems it is because of the torch version.

I am working on a windows cpu only environment, and manually installed latest pytorch. After that I tried to manually install pytorch-pretrained-bert 0.6.2 but still have error:

ERROR: Could not find a version that satisfies the requirement torch>=0.4.1 (from pytorch-pretrained-bert) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch>=0.4.1 (from pytorch-pretrained-bert)

This is my package list

Name Version Build Channel

attrs 19.3.0 py_0 anaconda
backcall 0.1.0 py37_0 anaconda
blas 1.0 mkl anaconda
bleach 3.1.0 py37_0 anaconda
boto3 1.10.8 pypi_0 pypi
botocore 1.13.8 pypi_0 pypi
ca-certificates 2019.10.16 0 anaconda
certifi 2019.9.11 py37_0 anaconda
cffi 1.12.3 py37h7a1dbc1_0
chardet 3.0.4 pypi_0 pypi
click 7.0 pypi_0 pypi
colorama 0.4.1 py_0 anaconda
cpuonly 1.0 0 pytorch
decorator 4.4.1 py_0 anaconda
defusedxml 0.6.0 py_0 anaconda
docutils 0.15.2 pypi_0 pypi
entrypoints 0.3 py37_0 anaconda
freetype 2.9.1 ha9979f8_1
icc_rt 2019.0.0 h0cc432a_1 anaconda
icu 58.2 ha66f8fd_1 anaconda
idna 2.8 pypi_0 pypi
importlib_metadata 0.23 py37_0 anaconda
intel-openmp 2019.5 281 anaconda
ipykernel 5.1.3 py37h39e3cac_0 anaconda
ipython 7.9.0 py37h39e3cac_0 anaconda
ipython_genutils 0.2.0 py37_0 anaconda
ipywidgets 7.5.1 py_0 anaconda
jedi 0.15.1 py37_0 anaconda
jinja2 2.10.3 py_0 anaconda
jmespath 0.9.4 pypi_0 pypi
joblib 0.14.0 pypi_0 pypi
jpeg 9c hfa6e2cd_1001 conda-forge
jsonschema 3.1.1 py37_0 anaconda
jupyter 1.0.0 py37_7 anaconda
jupyter_client 5.3.4 py37_0 anaconda
jupyter_console 6.0.0 py37_0 anaconda
jupyter_core 4.6.0 py37_0 anaconda
libpng 1.6.37 h2a8f88b_0 anaconda
libsodium 1.0.16 h9d3ae62_0 anaconda
libtiff 4.0.10 hb898794_2
m2w64-gcc-libgfortran 5.3.0 6
m2w64-gcc-libs 5.3.0 7
m2w64-gcc-libs-core 5.3.0 7
m2w64-gmp 6.1.0 2
m2w64-libwinpthread-git 5.0.0.4634.697f757 2
markupsafe 1.1.1 py37he774522_0 anaconda
mistune 0.8.4 py37he774522_0 anaconda
mkl 2019.5 281 anaconda
mkl_fft 1.0.12 py37h14836fe_0 anaconda
mkl_random 1.0.2 py37h343c172_0 anaconda
more-itertools 7.2.0 py37_0 anaconda
msys2-conda-epoch 20160418 1
nbconvert 5.6.0 py37_1 anaconda
nbformat 4.4.0 py37_0 anaconda
ninja 1.9.0 py37h74a9793_0
nltk 3.4.5 py37_0 anaconda
notebook 6.0.1 py37_0 anaconda
numpy 1.16.3 py37h19fb1c0_0 anaconda
numpy-base 1.16.3 py37hc3f5095_0 anaconda
olefile 0.46 py37_0
openssl 1.1.1 he774522_0 anaconda
pandas 0.23.4 py37h830ac7b_0 anaconda
pandoc 2.2.3.2 0 anaconda
pandocfilters 1.4.2 py37_1 anaconda
parso 0.5.1 py_0 anaconda
pickleshare 0.7.5 py37_0 anaconda
pillow 6.1.0 py37hdc69c19_0
pip 19.3.1 py37_0 anaconda
prometheus_client 0.7.1 py_0 anaconda
prompt_toolkit 2.0.10 py_0 anaconda
pycparser 2.19 py37_0
pygments 2.4.2 py_0 anaconda
pyqt 5.9.2 py37ha878b3d_0 anaconda
pyrsistent 0.14.11 py37he774522_0 anaconda
python 3.7.3 h8c8aaf0_1 anaconda
python-dateutil 2.8.0 py37_0 anaconda
pytorch 1.3.0 py3.7_cpu_0 [cpuonly] pytorch
pytorch-cpu 1.1.0 py3.7_cpu_1 pytorch
pytz 2019.3 py_0 anaconda
pywin32 223 py37hfa6e2cd_1 anaconda
pywinpty 0.5.5 py37_1000 anaconda
pyzmq 18.1.0 py37ha925a31_0 anaconda
qt 5.9.7 hc6833c9_1 conda-forge
qtconsole 4.5.5 py_0 anaconda
regex 2019.11.1 pypi_0 pypi
requests 2.22.0 pypi_0 pypi
s3transfer 0.2.1 pypi_0 pypi
sacremoses 0.0.35 pypi_0 pypi
send2trash 1.5.0 py37_0 anaconda
sentencepiece 0.1.83 pypi_0 pypi
setuptools 41.6.0 py37_0 anaconda
sip 4.19.13 py37ha925a31_0 anaconda
six 1.12.0 py37_0 anaconda
sqlite 3.29.0 he774522_0 anaconda
terminado 0.8.2 py37_0 anaconda
testpath 0.4.2 py37_0 anaconda
textblob 0.15.3 py_0 conda-forge
tk 8.6.8 hfa6e2cd_0
torchvision 0.4.1 py37_cpu [cpuonly] pytorch
torchvision-cpu 0.3.0 py37_cuNone_1 pytorch
tornado 6.0.3 py37he774522_0 anaconda
tqdm 4.36.1 py_0 anaconda
traitlets 4.3.3 py37_0 anaconda
urllib3 1.25.6 pypi_0 pypi
vc 14.1 h21ff451_3 anaconda
vs2015_runtime 15.5.2 3 anaconda
wcwidth 0.1.7 py37_0 anaconda
webencodings 0.5.1 py37_1 anaconda
wheel 0.33.6 py37_0 anaconda
widgetsnbextension 3.5.1 py37_0 anaconda
wincertstore 0.2 py37_0 anaconda
winpty 0.4.3 4 anaconda
xz 5.2.4 h2fa13f4_4
zeromq 4.3.1 h33f27b4_3 anaconda
zipp 0.6.0 py_0 anaconda
zlib 1.2.11 h62dcd97_3 anaconda
zstd 1.3.7 h508b16e_0

from finbert.

wjchicago avatar wjchicago commented on July 20, 2024

finally I managed install torch 1.1.0 by install its wheel:
https://download.pytorch.org/whl/cpu/torch-1.1.0-cp37-cp37m-win_amd64.whl
and then installed pytorch-pretrained-bert.

However when I run the test command it gives me the error as below. Do you have any idea about the error message?

(finbert) C:\Projects\Python\GitHub\finBERT>python predict.py --text_path test.txt --output_dir output/ --model_path models/classifier_model/finbert-sentiment
11/02/2019 20:37:45 - INFO - pytorch_pretrained_bert.modeling - loading archive file models/classifier_model/finbert-sentiment
11/02/2019 20:37:45 - INFO - pytorch_pretrained_bert.modeling - Model config {
"attention_probs_dropout_prob": 0.1,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"hidden_size": 768,
"initializer_range": 0.02,
"intermediate_size": 3072,
"max_position_embeddings": 512,
"num_attention_heads": 12,
"num_hidden_layers": 12,
"type_vocab_size": 2,
"vocab_size": 30522
}

Traceback (most recent call last):
File "predict.py", line 24, in
model = BertForSequenceClassification.from_pretrained(args.model_path,num_labels=3,cache_dir=None)
File "C:\Users\wjchi\Anaconda3\envs\finbert\lib\site-packages\pytorch_pretrained_bert\modeling.py", line 603, in from_pretrained
state_dict = torch.load(weights_path, map_location='cpu')
File "C:\Users\wjchi\Anaconda3\envs\finbert\lib\site-packages\torch\serialization.py", line 387, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File "C:\Users\wjchi\Anaconda3\envs\finbert\lib\site-packages\torch\serialization.py", line 564, in _load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, 'v'.

from finbert.

wjchicago avatar wjchicago commented on July 20, 2024

I can reproduce the problem with a simple script. Is the model correctly pickled? My pickle version is 4.0

import pickle
file = open('models/classifier_model/finbert-sentiment/pytorch_model.bin','rb')
model = pickle.load(file)
print(model)

from finbert.

doguaraci avatar doguaraci commented on July 20, 2024

Hi, could you try installing git-lfs on your system and then cloning the repo again?

from finbert.

wjchicago avatar wjchicago commented on July 20, 2024

Thank you for your hint! It works. Actually I doubt I terminated the downloading process by mistake in my first download so that the model file is broken.

from finbert.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.