Guest User

Untitled

a guest
Jul 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. public ArrayList<Weights> train(){
  2. if(tensorFlowInferenceInterface!=null){
  3. byte[] def = tensorFlowInferenceInterface.graph().toGraphDef();
  4. try(Graph graph = new Graph();
  5. Session session = new Session(graph);){
  6. graph.importGraphDef(def);
  7. session.runner().addTarget("init").run();
  8. Random random = new Random();
  9. for(int i = 1; i<=7; i++){
  10. for(int n = 0; n < 500; n++){
  11. float in = random.nextFloat();
  12. try(Tensor<Float> input = Tensors.create(in);
  13. Tensor<Float> target = Tensors.create(m*in + c);
  14. ){
  15. session.runner().feed("input", input)
  16. .feed("target", target)
  17. .addTarget("train")
  18. .run();
  19. }
  20. }
  21. weights.add(getVariables(session, i));
  22. }
  23. }
  24. }
  25. Log.d("Weights:", weights+"");
  26. return weights;
  27. }
Add Comment
Please, Sign In to add comment