Skip to content

Commit b685c8d

Browse files
author
xuming06
committed
add neo4j demo.
1 parent c85b344 commit b685c8d

6 files changed

Lines changed: 111 additions & 1 deletion

File tree

29t2t/nmt.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing[email protected])
4+
@description:
5+
"""
6+
7+
8+
# See what problems, models, and hyperparameter sets are available.
9+
# You can easily swap between them (and add new ones).
10+
t2t-trainer --registry_help
11+
12+
PROBLEM=translate_ende_wmt32k
13+
MODEL=transformer
14+
HPARAMS=transformer_base_single_gpu
15+
16+
DATA_DIR=$HOME/t2t_data
17+
TMP_DIR=/tmp/t2t_datagen
18+
TRAIN_DIR=$HOME/t2t_train/$PROBLEM/$MODEL-$HPARAMS
19+
20+
mkdir -p $DATA_DIR $TMP_DIR $TRAIN_DIR
21+
22+
# Generate data
23+
t2t-datagen \
24+
--data_dir=$DATA_DIR \
25+
--tmp_dir=$TMP_DIR \
26+
--problem=$PROBLEM
27+
28+
# Train
29+
# * If you run out of memory, add --hparams='batch_size=1024'.
30+
t2t-trainer \
31+
--data_dir=$DATA_DIR \
32+
--problem=$PROBLEM \
33+
--model=$MODEL \
34+
--hparams_set=$HPARAMS \
35+
--output_dir=$TRAIN_DIR
36+
37+
# Decode
38+
39+
DECODE_FILE=$DATA_DIR/decode_this.txt
40+
echo "Hello world" >> $DECODE_FILE
41+
echo "Goodbye world" >> $DECODE_FILE
42+
echo -e 'Hallo Welt\nAuf Wiedersehen Welt' > ref-translation.de
43+
44+
BEAM_SIZE=4
45+
ALPHA=0.6
46+
47+
t2t-decoder \
48+
--data_dir=$DATA_DIR \
49+
--problem=$PROBLEM \
50+
--model=$MODEL \
51+
--hparams_set=$HPARAMS \
52+
--output_dir=$TRAIN_DIR \
53+
--decode_hparams="beam_size=$BEAM_SIZE,alpha=$ALPHA" \
54+
--decode_from_file=$DECODE_FILE \
55+
--decode_to_file=translation.en
56+
57+
# See the translations
58+
cat translation.en
59+
60+
# Evaluate the BLEU score
61+
# Note: Report this BLEU score in papers, not the internal approx_bleu metric.
62+
t2t-bleu --translation=translation.en --reference=ref-translation.de

30neo4j/01node.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
7+
from py2neo import Node,Relationship
8+
9+
a = Node('Person',name='Alice')
10+
b = Node('Person',name='Bob')
11+
r = Relationship(a,"KNOWS",b)
12+
print(a,b,r)
13+
14+
s = a|b|r
15+
print(s)
16+

30neo4j/02graph.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
7+
from py2neo import Node, Relationship, Graph
8+
9+
a = Node('Person', name='Alice')
10+
b = Node('Person', name='Bob')
11+
r = Relationship(a, 'KNOWS', b)
12+
s = a | b | r
13+
print(s)
14+
15+
print(r)
16+
print(a)

30neo4j/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ torch
1010
click
1111
xlearn
1212
wave
13-
pyaudio
13+
pyaudio
14+
py2neo

tool/demo.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
import control
7+
control.append('a')
8+
9+
print('a')

0 commit comments

Comments
 (0)