Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

45
LINES

< > BotCompany Repo | #1020098 // Unpickle Sort-of-CLEVR Dataset [basically OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 36155K of libraries. Click here for Pure Java version (10127L/74K).

1  
!7
2  
3  
lib 1400166 // jython 2.7
4  
5  
import org.python.core.*;
6  
import org.python.modules.cPickle;
7  
8  
static LS colors = splitAtComma("red, blue, green, orange, yellow, gray");
9  
10  
p-exp {
11  
  File f = userDir("dev/Relational_Network_Tensorflow-master/data/sort-of-clevr.100-10.pickle");
12  
13  
  PyFile pyFile = new(bufferedInputStream(f));
14  
  O o = cPickle.load(pyFile);
15  
  print("Loaded: " + className(o));
16  
  
17  
  L trainAndTest = cast o;
18  
  for (L x : (L<L>) trainAndTest) {
19  
    print(l(x) + " examples");
20  
    L entry = cast first(x);
21  
    print(l(entry));
22  
    L<LL<Double>> img = (L) entry.get(0);
23  
    L<L> relations = cast entry.get(1);
24  
    L<L> norelations = cast entry.get(2);
25  
    //print("img: " + sfu(img)); // img is a LLL<Double>
26  
    showImage(rgbImageFromLLLDouble255((L) img));
27  
    LL<Double> relQuestions = (L) first(relations);
28  
    L<Double> relAnswers = (L) second(relations);
29  
    LL<Double> norelQuestions = (L) first(norelations);
30  
    L<Int> norelAnswers = (L) second(norelations);
31  
    print("relations:" + sfu(relations));
32  
    print("norelations:" + sfu(norelations));
33  
    for i over norelQuestions: {
34  
      L<Double> q = norelQuestions.get(i);
35  
      Int a = norelAnswers.get(i);
36  
      S color = get(colors, indexOf(q, 1.0));
37  
      S subtype = get(
38  
        ll("query shape->rectangle/circle",
39  
           "query horizontal position->yes/no",
40  
           "query vertical position->yes/no"),
41  
        indexOf(q, 8, 1.0)-8);
42  
      print("norel: " + q + " => " + a + ". color: " + color + ", subtype: " + subtype);
43  
    }
44  
  }
45  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020098
Snippet name: Unpickle Sort-of-CLEVR Dataset [basically OK]
Eternal ID of this version: #1020098/26
Text MD5: e83b8b3ae7c8020ff8586a52403a3ad0
Transpilation MD5: 3b1821df3aa6b2e06ac3805e18fc5d27
Author: stefan
Category: javax / python
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-07 16:16:16
Source code size: 1557 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 352 / 877
Version history: 25 change(s)
Referenced in: [show references]