Coder Social home page Coder Social logo

nermultimodal's Introduction

NERmultimodal

1. Introduction

(unofficial) Keras ReImplementation of "Adaptive Co-attention Network for Named Entity Recognition in Tweets". The original code is in NERmultimodal .

2. Requirements

  1. Python 2.7 or higher
  2. Keras 1.2, the backend is theano.
  3. The image features were extracted from 16-layer VGGNet. Before extracting the features, you need to download a pretrained model -- vgg16_weights_th_dim_ordering_th_kernels_notop.h5.
  4. Moreover, you need to download the word embedding trained by tweets from http://pan.baidu.com/s/1boSlljL (which is slow to be downloaded, you can only download word2vec_200dim.model in /word2vec path).

3. Get Started

To get the right environment settled, you can create an anaconda virtual env by

conda create -n env_name python=2.7

Then install these packages one by one

pip install keras==1.2.2
pip install h5py
pip install pip==9.0.1
pip install gensim==3.8.3
conda install mkl-service

ps: pip 9.0.1 is used to install gensim 3.8.3

All packages that are needed to run the code can be seen in requirements.txt (not including the feature extraction part).

For feature extraction, you need to install opencv by

pip install opencv-python==3.1.0.0

4. Download

I put all the data needed in Baidu Pan, including:

  • vgg16_weights_th_dim_ordering_th_kernels_notop.h5
  • word2vec_200dim.model
  • image features extracted from 16-layer VGGNet

Link: https://pan.baidu.com/s/1jpgunQHnTqdtmp7c1uZGzg password: 5wrw

5. Details

I rewrite a few parts in the original code to make it run.

In vgg_image_feature.py line 85, I change the original code to

for text_filename in ['train', 'dev', 'test']:
    with open(os.path.join('./data/', text_filename), 'r') as f:
        for line in f:
            if line.startswith("IMGID:"):
                img_id_list.append(line.replace("IMGID:", "").strip())

In multimodal_ner.py, I do not use the CRF from keras.layer, but use the CRF implementation from emnlp2017-bilstm-cnn-crf , which can be downloaded here . Its CRF implementation file is in the /neuralnets/keraslayers path.

After set all the requirements above, you can run the code smoothly.

6. More Information

For more Information, please check the original code .

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.