Tensorflow LSTM doesn't work - android

I've a problem with CRNN TensorFlow model when try to run it on Android (TensorFlowInferenceInterface). When I run it in Python environment everything seems to work correctly.
On Android I get following error:
java.lang.IllegalArgumentException: Expected len(indices) == values.shape[0], but saw: 25 vs. 30
[[Node: shadow/LSTMLayers/stack_bidirectional_rnn/cell_0/bidirectional_rnn/bw/bw/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3 = TensorArrayScatterV3[T=DT_FLOAT, _class=["loc:#shado.../transpose"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](shadow/LSTMLayers/stack_bidirectional_rnn/cell_0/bidirectional_rnn/bw/bw/TensorArray_1, shadow/LSTMLayers/stack_bidirectional_rnn/cell_0/bidirectional_rnn/bw/bw/TensorArrayUnstack/range, shadow/LSTMLayers/stack_bidirectional_rnn/cell_0/bidirectional_rnn/bw/transpose, shadow/LSTMLayers/stack_bidirectional_rnn/cell_0/bidirectional_rnn/bw/bw/TensorArray_1:1)]]
at org.tensorflow.Session.run(Native Method)
Any ideas?

len(indices) == values.shape[0], but saw: 25 vs. 30
The program expects these two values to be the same. It does not seem like an android error. Could you verify the dimensions of your tensors and see whether they match with what you expect them to be?

Related

Unresolved reference: AndroidJUnit4 An annotation argument must be a compile-time constant

I'm a complete beginner to coding and Android Studio. I've been trying to follow along with basic "hello world" guides and to my dismay, I am having zero luck.
I keep getting error messages even when the code seems to be correct. I've tried searching for the fix, but I'm honestly not sure what to search for as I'm not sure where I am going wrong.
I believe that it is a Kotlin issue. I've tried reinstalling android studio, resetting the settings and ensuring updates are current.
Code:
fun main(args:Array<String>) {
println("hello world!")
}
Error log:
build failed 9 s 875 ms
Run build 9 s 583 ms
null
C:/Users/guilder/AndroidStudioProjects/MyApplication3
app/src/androidTest/java
com/example/myapplication/ExampleInstrumentedTest.kt
Unresolved reference: ext
Unresolved reference: AndroidJUnit4
An annotation argument must be a compile-time constant
Okay, it's a bit late, but, if you are still struggling with this issue, just delete file which leads to crash. This is
C:/Users/guilder/AndroidStudioProjects/MyApplication3/app/src/androidTest/java
com/example/myapplication/ExampleInstrumentedTest.kt
file. Have a nice day!

Error building openframeworks for android: “ invalid use of incomplete type ‘class Poco::Path’”

I am trying to build an android application with OF. The application runs in two other computers. However, it does not work on mine. I am using a mac.
I run the command "make AndroidDebug" in the project folder, and this is the error I have:
/Library/openFrameworks/addons/ofxHTTP/libs/ofxHTTP/src/PostRouteFileHandler.cpp:98:46: error: invalid use of incomplete type 'class Poco::Path'
ss << Poco::Path(formFileName).getExtension();
I have installed poco, but nothing changes afterwards.
What can I do to solve this?
Thanks
Have you included Poco/Path.h?
A forward declaration might appeared earlier (possibly in another header) without complete definition.

android kernel build (first time)

Ok so first off,
Im brand new to android dev. This is my first attempt at any form of kernel anything. I have a limited knowledge of java and python, but no C.
I have a galaxy tab 4 sm-t330nu running 4.4.2. its running a qualcomm snapdragon 400 msm8226 cpu. im simply trying to do a test build with a vanilla kernel at this point. (also my build environment is the newest kali 1.1 and im loosely following the tutorial at https://github.com/offensive-security/kali-nethunter/wiki/Porting-Nethunter)
so i have all of the required dependencies (i hope), and ive downloaded my source from samsung opensource. unzipped and went through the available defconfigs. after finding "msm8226-sec_milletwifiue_defconfig" i decided it was the most likely candidate for my tablet. (when doing a custom recovery i remember it being "philz touch milletwifiue something)
Ive done my exports (arch= subarch= cross_compile=) and all seems well. When i run a build following exactly as the tutorial says (using the defconfig in their example as a test) i receive an error stating "must define variant_defconfig". So i instead do "make variant_defconfig=msm8974_sec_defconfig" and it builds great.
Now the issue:
When i change "msm8974_sec_defconfig" to my actual msm8226 i receive an error on every build that i cannot seem to workaround. (cut down for size)
CC arch/arm/kernel/armksyms.o
CC arch/arm/kernel/module.o
AS arch/arm/kernel/sleep.o
CC arch/arm/kernel/suspend.o
CC arch/arm/kernel/io.o
arch/arm/kernel/io.c: In function '_memcpy_fromio':
arch/arm/kernel/io.c:14:3: error: implicit declaration of function 'nop' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[1]: *** [arch/arm/kernel/io.o] Error 1
make: *** [arch/arm/kernel] Error 2
My exact bash line reads
make VARIANT_DEFCONFIG=msm8226-sec_milletwifiue_defconfig
Any assistance on clearing this up would be great
edit
although im not familiar with c, it seems to me that '_memcpy_fromio' is where the error lies. and my google searches tell me that the error is that a function is used without being declared. however i dont know if memcpy is a function? or is the function within class memcpy (dont know if c has classes just closest equivalent that i know of) how do i debug this code and declare what needs to be declared (more importantly, if this is a stock kernel thats used by thousands of devices, how can it possibly have an undeclared function?
/edit
found the answer! needed
#import linux/modules.h
#import linux/kernel.h

Invalid Argument while Creating Socket

I'm facing problem while creating a socket, with configuration as mentioned below,
Code :
sid = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
Error Details : Number - 22, String - Invalid argument
The error is not quite consistent. Out of 10 run this will happen for 3 - 4 times.
The code is compiled for the Android OS (For MAC & Windows platform it work for 10 out of 10).
Please suggest the possible reason and also fix for this.
Please check the permission of directory/path from where your executable run.
see this link for similar error and fix on windows
http://social.msdn.microsoft.com/Forums/en-US/wsk/thread/3076a9cd-57a0-418d-8de1-07adc3b486bb/

Problems with build.xml when using the Android ADK to communicate with an Arduino Mega ADK

So a few days ago I got my hands on an Arduino Mega ADK board, and the last couple of nights I have been setting up my development environment, getting to grips with the tools etc. The tools and libraries all work fine, for example I can get a program written in the Processing IDE to compile and run on an Asus Eee Pad Transformer TF101 running Android 4.03. But when I get it to try to compile and run one of the pre-written examples, it gives me a compiler error:
Android SDK Tools Revision 20
Installed at C:\NVPACK\android-sdk-windows
Project Type: Application
Project Target: Android 2.3.3
API level: 10
Library dependencies:
No Libraries
API<=15: Adding annotations.jar to the classpath.
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
No AIDL files to compile.
No RenderScript files to compile.
Generating resource IDs...
Generating BuildConfig class.
BUILD FAILED
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:680: The following error occurred while executing this line:
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:693: Compile failed; see the compiler error output for details.
Total time: 7 seconds
And that's all the console seems to output as well, which is rather frustrating! As far as I'm aware all of my SDK versions, tools and plugins are all up to date. I've tried this using a Linux partition I have on my hard drive and it produces the same error message, although it mentions a problem with the package com.Android.future.UsbAccessory. Given what I've seen, it seems that the problem is with the tools, either my directory structure doesn't match up to what the correct setup is, or something else is wrong :S. If anyone has had similar problems, some help would be smashing! (For the record, my setup was done using the instructions on the Arduino website, although I already had the Android SDK tools installed).
Will Scott-Jackson
It sounds like your haven't added in the support library to your project and/or you haven't downloaded it into your Android SDK.
The ADK1 demokit app targets API Level 10 (Android 2.3.3); That means you need to use the support libraries in your project and that's why the compiler is complaining about level 10 library dependencies not being available. The support libraries are a separate download in the SDK Manager, so you might not have them in your development environment.
In Android API Level 12 and higher, the USB Accessory protocol was added to the framework API, so there are two different ways to use the accessory protocol. So, you don't have to use the support libraries if you are targeting Honeycomb and higher versions, but you'll have to update the demokit app code to make this work.
Hope this helps.
So I've double checked my setup and started working on a project I had in mind, it seems to import the libraries appropriately. So far so good, but when I input:
ArduinoAdkUsb arduino;
void setup() {
arduino = new ArduinoAdkUsb(this);
//Other UI initialisation etc.
}
I get this error:
##name## ##version## by ##author##
FATAL EXCEPTION: Animation Thread
java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager
at cc.arduino.ADKCommunication.<init>(Unknown Source)
at cc.arduino.ArduinoAdkUsb.<init>(Unknown Source)
at
processing.android.test.sketch_120730a.
sketch_120730a.setup(sketch_120730a.java:48)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:856)
After the app has been built and installed onto the Android tablet I am using. Any thoughts how I can over come this? From what I can tell, this has no problem finding com.android.future.usb.manager to compile and install the program, but once it tries to run it can find it.
Based on this tutorial from http://stream.tellart.com/controlling-arduino-with-android/
In the examples RGB_Arduino the name, version and author variables are set at the top of the sketch.
Try adding in this section of code at the top of your arduino sketch just underneath the library imports
// accessory descriptor. It's how Arduino identifies itself to Android
char applicationName[] = "Mega_ADK"; // the app on your phone
char accessoryName[] = "Mega_ADK"; // your Arduino board
char companyName[] = "Freeware";
// make up anything you want for these
char versionNumber[] = "1.0";
char serialNumber[] = "1";
char url[] = "http://labs.arduino.cc/adk/"; // the URL of your app online
//initialize the accessory:
AndroidAccessory usb(companyName, applicationName,
accessoryName,versionNumber,url,serialNumber);

Categories

Resources