import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.nio.ByteBuffer; import java.nio.ByteOrder; import org.tensorflow.lite.Interpreter; /** Runs under Android app_process with the matched TensorFlow Lite 2.16.1 AARs. */ public final class TrainingRuntimeCheck { static float[][][][] image(int h,int w) { float[][][][] x=new float[1][3][h][w]; for(int c=0;c<3;c++)for(int y=0;y inputs(Object... values) { Map out=new HashMap<>();for(int n=0;n(),"save"); check(new File(checkpoint).length()>0,"empty checkpoint"); train(i,x,target);continued=infer(i,x,classes); } try(Interpreter restored=new Interpreter(model,options)) { restored.runSignature(inputs("checkpoint_path",checkpoint),new HashMap<>(),"restore"); check(Arrays.equals(trained,infer(restored,x,classes)),"restore differs"); train(restored,x,target);check(Arrays.equals(continued,infer(restored,x,classes)),"optimizer resume differs"); } System.out.println("ANDROID_TRAINING_PASS {\"model\":\""+model.getName()+"\",\"mixed_shapes\":[[224,224],[192,320]],\"first_loss\":"+first+",\"last_loss\":"+last+",\"restart_exact\":true,\"optimizer_resume_exact\":true,\"runtime\":\""+org.tensorflow.lite.TensorFlowLite.runtimeVersion()+"\",\"device\":\"Android emulator x86_64\"}"); } }