Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
hapi
提交
cea791c6
H
hapi
项目概览
PaddlePaddle
/
hapi
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hapi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cea791c6
编写于
4月 27, 2020
作者:
W
wangxiao1021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove unnecessary import
上级
461b3e28
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
12 deletion
+12
-12
examples/sentiment_classification/README.md
examples/sentiment_classification/README.md
+10
-10
examples/sentiment_classification/models.py
examples/sentiment_classification/models.py
+2
-2
未找到文件。
examples/sentiment_classification/README.md
浏览文件 @
cea791c6
...
...
@@ -22,14 +22,14 @@ python版本依赖python 2.7或python 3.5及以上版本。
#### 代码下载及环境变量设置
克隆代码库到本地,并设置`PYTHONPATH`环境变量
克隆代码库到本地,并设置
`PYTHONPATH`
环境变量
```bash
git clone https://github.com/PaddlePaddle/hapi
cd hapi
export PYTHONPATH=$PYTHONPATH:`pwd`
cd examples/sentiment_classification
```
```
shell
git clone https://github.com/PaddlePaddle/hapi
cd
hapi
export
PYTHONPATH
=
$PYTHONPATH
:
`
pwd
`
cd
examples/sentiment_classification
```
#### 数据准备
...
...
@@ -55,7 +55,7 @@ python sentiment_classifier.py
利用已有模型,可以运行下面命令,对未知label的数据(test.tsv)进行预测。
模型预测需确保
`senta.yaml`
中
`do_infer`
属性为
`True`
。
模型预测需确保
`senta.yaml`
中
`do_infer`
属性
置
为
`True`
。
```
shell
python sentiment_classifier.py
...
...
@@ -92,8 +92,8 @@ python sentiment_classifier.py
```
text
特 喜欢 这种 好看的 狗狗 1
这 真是 惊艳 世界 的 中国 黑科技 1
环境 特别 差 ,脏兮兮 的,再也 不去 了 0
这 真是 惊艳 世界 的 中国 黑科技
1
环境 特别 差 ,脏兮兮 的,再也 不去 了
0
```
#### 代码结构说明
...
...
examples/sentiment_classification/models.py
浏览文件 @
cea791c6
...
...
@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
paddle.fluid
as
fluid
from
paddle.fluid.dygraph.nn
import
Conv2D
,
Pool2D
,
Linear
,
Embedding
from
paddle.fluid.dygraph.nn
import
Linear
,
Embedding
from
paddle.fluid.dygraph.base
import
to_variable
import
numpy
as
np
from
hapi.model
import
Model
from
hapi.text.text
import
GRUEncoderLayer
as
BiGRUEncoder
from
hapi.text.te
x
t
import
BOWEncoder
,
CNNEncoder
,
GRUEncoder
from
hapi.text.te
s
t
import
BOWEncoder
,
CNNEncoder
,
GRUEncoder
class
CNN
(
Model
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录