Tutorials on training the Skip-thoughts vectors for features extraction of sentence.

简介: Tutorials on training the Skip-thoughts vectors for features extraction of sentence.    1. Send emails and download the training dataset.

Tutorials on training the Skip-thoughts vectors for features extraction of sentence. 

 

  1. Send emails and download the training dataset. 

    the dataset used in skip_thoughts vectors is from [BookCorpus]: http://yknzhu.wixsite.com/mbweb 

    first, you should send a email to the auther of this paper and ask for the link of this dataset. Then you will download the following files: 

    

    unzip these files in the current folders. 

  2. Open and download the tensorflow version code.   

    Do as the following links: https://github.com/tensorflow/models/tree/master/skip_thoughts 

    Then, you will see the processing as follows: 

          

    [Attention]  when you install the bazel, you need to install this software, but do not update it. Or, it may shown you some errors in the following operations. 

 

  3. Encoding Sentences :   

    (1). First, open a terminal and input "ipython" : 

    (2). input the following code to the terminal: 

ipython  # Launch iPython.

In [0]:

# Imports.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import os.path
import scipy.spatial.distance as sd
from skip_thoughts import configuration
from skip_thoughts import encoder_manager

In [1]:
# Set paths to the model.
VOCAB_FILE = "/path/to/vocab.txt"
EMBEDDING_MATRIX_FILE = "/path/to/embeddings.npy"
CHECKPOINT_PATH = "/path/to/model.ckpt-9999"
# The following directory should contain files rt-polarity.neg and
# rt-polarity.pos.

 

    For this moment, you already defined the environment, then, you need also do the followings: 

In [2]:
# Set up the encoder. Here we are using a single unidirectional model.
# To use a bidirectional model as well, call load_model() again with
# configuration.model_config(bidirectional_encoder=True) and paths to the
# bidirectional model's files. The encoder will use the concatenation of
# all loaded models.
encoder = encoder_manager.EncoderManager()
encoder.load_model(configuration.model_config(),
                   vocabulary_file=VOCAB_FILE,
                   embedding_matrix_file=EMBEDDING_MATRIX_FILE,
                   checkpoint_path=CHECKPOINT_PATH)

In [3]:
# Load the movie review dataset.
data = [' This is my first attempt  to the tensorflow version skip_thought_vectors ... ']

 

  The, it's time to get the 2400# features now. 

In [4]:
# Generate Skip-Thought Vectors for each sentence in the dataset.
encodings = encoder.encode(data)
print(encodings)
print(encodings[0]) 

  

  You can see the results of the algorithm as followings: 

  

 

  Now that, you have obtain the features of the input sentence. you can now load your texts to obtain the results. Come on ... 

 

相关文章
|
8月前
|
存储 编解码 网络协议
基于STM32+GPRS+GPS+Google Earth的车载导航定位系统
本系统以STM32F407ZGT6为核心控制器,集成GPS模块(NEO-6M) 实现位置定位,GPRS模块(SIM800C) 实现数据远程传输,通过KML格式将位置数据上传至服务器,最终在Google Earth中实时显示车辆轨迹。系统支持实时定位、轨迹回放、超速报警功能,适用于物流追踪、车队管理、个人导航等场景。
|
4月前
|
弹性计算 小程序 iOS开发
阿里云无影云电脑个人版指南:快速购买、选择无影套餐、配置云电脑、连接及使用全流程
阿里云无影云电脑个人版,支持Windows/macOS/手机多端接入,提供黄金至黑金6档灵活套餐(14.9元/月起),含系统盘、数据盘、带宽及灵豆配额,适用于办公、学习、设计与游戏。一键配置、即连即用,休眠不计费,数据安全可靠。
1595 2
|
4月前
|
SQL 数据采集 监控
别再堆工具了!从 0 到 1 搭建小型生产级数据平台,只需要这份落地清单
别再堆工具了!从 0 到 1 搭建小型生产级数据平台,只需要这份落地清单
271 1
|
5月前
|
人工智能 定位技术 API
阿里云轻量服务器部署 Dify 全流程:模型接入、知识库创建、应用嵌入网站
Dify是开源大语言模型(LLM)应用开发平台,支持快速构建知识库问答系统。本文详解如何通过阿里云轻量应用服务器+Dify镜像,5步完成部署:选服务器、配镜像、选地域、登录后台、接入模型并创建专属AI助手,零代码集成企业知识库。阿里云轻量应用服务器官网:https://t.aliyun.com/U/dwftch
|
7月前
|
运维 容灾 测试技术
香港机房等级怎么看?Tier III是什么水平?
很多企业在选择香港服务器时,只关注带宽、CPU 和价格,却忽略了真正影响稳定性的核心因素——机房等级。 实际上,机房等级直接决定服务器是否稳定、是否容易宕机、能否在线维护,以及发生故障后的恢复能力。尤其对于跨境电商、SaaS平台、金融系统、直播业务来说,机房等级甚至比服务器配置更重要。 因此,了解 香港机房等级,已经成为企业部署海外业务时必须掌握的一项基础知识。
712 1
|
Linux 开发工具
如何在 Linux 中编辑配置文件?
如何在 Linux 中编辑配置文件?
1057 2
如何在 Linux 中编辑配置文件?
|
存储 人工智能 缓存
AI变革药物研发:深势科技的云原生实践之路
阿里云助力深势科技推出创新的玻尔Bohrium®科研云平台和Hermite®药物计算设计平台,并持续完善。这两项先进的工业设计与仿真基础设施成果通过AI技术赋能科学研究和工业研发,不仅大幅缩短了药物研发周期,降低了成本,还显著提高了研发成功率,为生物医药行业带来了前所未有的变革,这是AI for Science领域的重大突破。
1309 38
|
数据采集 存储 安全
一文讲清数据要素,数据资产,数据治理和数字资产
本文系统梳理了数据要素、数据资产、数据治理与数字资产四大核心概念。数据要素确立数据作为基础生产要素的战略地位;数据资产是企业可控制并带来经济利益的数据资源;数据治理是保障数据质量与安全的管理框架;数字资产则是涵盖数据资产在内的所有数字化有价值资产的统称。厘清四者关系,构建清晰数据认知体系,助力企业高效决策与价值实现。
|
存储 缓存 API
类似ComfyUI和Midjourney这样的文生图图生图应用的API与服务架构该怎么设计
文生图图生图应用的API与服务架构分析。或和微服务类似,但是不同。ComfyUI其 API 架构设计为我们理解此类应用提供了很好的参考模型。但距离生产级别的应用差距还有很远。
1139 0
|
人工智能 JSON 供应链
揭秘电商 API 接口,让多平台库存实时更新不是梦
在电商多平台销售中,库存同步是关键难题。本文解析电商 API 接口如何实现库存实时更新,提升效率、减少超卖,保障客户体验与品牌信誉。