Skip to content

Instantly share code, notes, and snippets.

View bartvollebregt's full-sized avatar
🐙
Octo

Bart Vollebregt bartvollebregt

🐙
Octo
View GitHub Profile
@bartvollebregt
bartvollebregt / convert_to_tflite.py
Created September 4, 2020 06:26
Yolov5 to .tflite
import tensorflow as tf
def wrap_frozen_graph(graph_def, inputs, outputs):
def _imports_graph_def():
tf.compat.v1.import_graph_def(graph_def, name="")
wrapped_import = tf.compat.v1.wrap_function(_imports_graph_def, [])
import_graph = wrapped_import.graph
### Keybase proof
I hereby claim:
* I am bartvollebregt on github.
* I am bartvollebregt (https://keybase.io/bartvollebregt) on keybase.
* I have a public key whose fingerprint is 127F BBE5 AE30 D419 1581 32C1 65AC D1FF 832F FBC0
To claim this, I am signing this object:
private static List<List<List<Writable>>> prepareTempData(List<String> rawStrings, int from, int to) {
List<List<List<Writable>>> topSequences = new ArrayList<>();
List<List<Writable>> listOfSequences = new ArrayList<>();
boolean first = true;
for(int i=from;i < (to - 1);i++) {
if(first && from == 0) {
===DATA===
===========INPUT===================
[[8.60, 8.80, 8.80, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.80, 8.80, 8.90, 8.70, 8.70, 8.70, 8.70, 8.70, 8.70, 8.70, 8.70, 8.80, 8.80, 8.80, 8.80, 8.70, 8.70, 8.70, 8.60, 8.50, 8.50, 8.40, 8.40, 8.30, 8.20, 8.20, 8.20, 8.10, 8.00, 8.00, 8.00, 7.90, 7.80, 7.90, 8.00, 7.90, 7.80, 7.80, 7.80, 7.80, 7.80, 7.80, 7.70, 7.70, 7.60, 7.60, 7.60, 7.60, 7.60, 7.60, 7.60, 7.70, 7.50, 7.60, 7.60, 7.70, 7.70, 7.90, 7.90, 8.10, 8.00, 8.10, 8.30, 8.40, 8.50, 8.70, 8.70, 8.80, 8.90, 8.90, 8.90, 8.90, 9.00, 8.90, 8.90, 8.90, 8.90, 8.70, 8.70, 8.70, 8.70, 8.70, 8.60, 8.60, 8.60, 8.50, 8.60, 8.50, 8.30, 8.20, 8.00, 7.90, 7.90, 7.90, 7.80, 7.90, 7.90, 7.80, 7.80, 7.80, 7.80, 7.80, 7.70, 7.70, 7.70, 7.60, 7.60, 7.60, 7.60, 7.60, 7.60, 7.50, 7.50, 7.50, 7.50, 7.50, 7.50, 7.60, 7.60, 7.50, 7.50, 7.50, 7.50, 7.50, 7.40, 7.40, 7.40, 7.50, 7.40, 7.50, 7.60, 7.70, 7.70, 7.90, 8.20, 8.50, 8.70, 8.80, 8.90, 8.90, 8.80, 8.80, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.9
System.out.println("===DATA===");
System.out.println(trainData);
System.out.println(testData);
//Normalize data, including labels (fitLabel=true)
NormalizerMinMaxScaler normalizer = new NormalizerMinMaxScaler(0, 1);
normalizer.fitLabel(true);
normalizer.fit(trainData);
normalizer.transform(trainData);
tempArray min 1:
[8.60, 8.80, 8.80, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.80, 8.80, 8.90, 8.70, 8.70, 8.70, 8.70, 8.70, 8.70, 8.70, 8.70, 8.80, 8.80, 8.80, 8.80, 8.70, 8.70, 8.70, 8.60, 8.50, 8.50, 8.40, 8.40, 8.30, 8.20, 8.20, 8.20, 8.10, 8.00, 8.00, 8.00, 7.90, 7.80, 7.90, 8.00, 7.90, 7.80, 7.80, 7.80, 7.80, 7.80, 7.80, 7.70, 7.70, 7.60, 7.60, 7.60, 7.60, 7.60, 7.60, 7.60, 7.70, 7.50, 7.60, 7.60, 7.70, 7.70, 7.90, 7.90, 8.10, 8.00, 8.10, 8.30, 8.40, 8.50, 8.70, 8.70, 8.80, 8.90, 8.90, 8.90, 8.90, 9.00, 8.90, 8.90, 8.90, 8.90, 8.70, 8.70, 8.70, 8.70, 8.70, 8.60, 8.60, 8.60, 8.50, 8.60, 8.50, 8.30, 8.20, 8.00, 7.90, 7.90, 7.90, 7.80, 7.90, 7.90, 7.80, 7.80, 7.80, 7.80, 7.80, 7.70, 7.70, 7.70, 7.60, 7.60, 7.60, 7.60, 7.60, 7.60, 7.50, 7.50, 7.50, 7.50, 7.50, 7.50, 7.60, 7.60, 7.50, 7.50, 7.50, 7.50, 7.50, 7.40, 7.40, 7.40, 7.50, 7.40, 7.50, 7.60, 7.70, 7.70, 7.90, 8.20, 8.50, 8.70, 8.80, 8.90, 8.90, 8.80, 8.80, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.90, 8.80, 8.70, 8.70, 8.6
package org.deeplearning4j.examples.recurrent.regression;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.Nd4j;
import java.util.Arrays;
import java.util.List;
/**
* Created by bart on 22-1-17.
- Tried setting the learning rate to 0.0001
Result: Only getting 7.77 as output
- Tried setting the learning rate to 0.0002
Result: Predicted values increasing at every epoch, eventually outputting ? for too large Integer
- Tried setting the learning rate to 0.0002 with 10 epochs
Result: Predicted values still increasing, ending with very high predicted values.
Starting to thinks that this can't really be a setting problem...
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
8.4
8.6
8.8
8.8
8.9
8.9
8.9
8.9
8.9
8.9
package org.deeplearning4j.examples.recurrent.regression;
import org.datavec.api.records.reader.SequenceRecordReader;
import org.datavec.api.records.reader.impl.collection.CollectionSequenceRecordReader;
import org.datavec.api.writable.DoubleWritable;
import org.datavec.api.writable.Writable;
import org.deeplearning4j.api.storage.StatsStorage;
import org.deeplearning4j.datasets.datavec.SequenceRecordReaderDataSetIterator;
import org.deeplearning4j.eval.RegressionEvaluation;