aboutsummaryrefslogtreecommitdiffstats
path: root/sample-apps
diff options
context:
space:
mode:
authorLester Solbakken <lesters@yahoo-inc.com>2016-09-15 09:06:48 +0200
committerLester Solbakken <lesters@yahoo-inc.com>2016-09-15 09:06:48 +0200
commit2d749a98fa0e459418f6da71f29e325ec2593d01 (patch)
tree6aaa2f8e742aa10cad50424a6c052c9c6b250b5b /sample-apps
parente4e489dfdca58eaf500b81de121d76b98a008423 (diff)
Sigmoid and relu are now native functions
Diffstat (limited to 'sample-apps')
-rw-r--r--sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd14
-rw-r--r--sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java5
2 files changed, 3 insertions, 16 deletions
diff --git a/sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd b/sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd
index 9011a559f1e..5069b9302eb 100644
--- a/sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd
+++ b/sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd
@@ -55,7 +55,7 @@ search blog_post {
}
- rank-profile tensor {
+ rank-profile default {
first-phase {
expression {
sum(query(user_item_cf) * attribute(user_item_cf))
@@ -65,7 +65,7 @@ search blog_post {
constant W_hidden {
file: constants/W_hidden.json
- type: tensor(input[20],hidden[40]) # user_item_cf
+ type: tensor(input[20],hidden[40])
}
constant b_hidden {
@@ -97,16 +97,6 @@ search blog_post {
expression: sum(x * y, dim)
}
- # Not valid. Needs to be a predefined function.
- macro relu(x) {
- expression: max(0, x) # 0 should be a constant tensor with 0 values
- }
-
- # Not valid. Needs to be predefined function.
- macro sigmoid(x) {
- expression: 1 / (1 + exp(-x))
- }
-
# The input to the neural network is the concatenation of the document and query vectors
macro nn_input() {
expression {
diff --git a/sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java b/sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java
index 5bbd7140cb8..c142c0e0986 100644
--- a/sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java
+++ b/sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java
@@ -35,10 +35,7 @@ public class BlogTensorSearcher extends Searcher {
}
QueryTreeUtil.andQueryItemWithRoot(query, notItem);
- // Modify the ranking by using the 'tensor' rank-profile (as defined in blog_post.sd)...
- query.properties().set(new CompoundName("ranking"), "tensor");
-
- // ... and setting 'query(user_item_cf)' used in that rank-profile
+ // Send the user profile to the ranking framework.
query.getRanking().getFeatures().put("query(user_item_cf)", toTensor(userItemCfProperty));
}