ERROR: LoadError: LoadError: syntax: "()" is not a valid function argument name - tensorflow

While trying to load TensorFlow in Julia, I gets the error
ERROR: LoadError: LoadError: syntax: "()" is not a valid function argument name
I could not get the solution. I am using Ubuntu and Julia version 0.6.0
The problems:
julia> using TensorFlow
INFO: Precompiling module TensorFlow.
WARNING: Loading a new version of TensorFlow.jl for the first time. This initial load can take around 5 minutes as code is precompiled; subsequent usage will only take a few seconds.
ERROR: LoadError: LoadError: syntax: "()" is not a valid function argument name
Stacktrace:
[1] include_from_node1(::String) at ./loading.jl:569
[2] include(::String) at ./sysimg.jl:14
[3] include_from_node1(::String) at ./loading.jl:569
[4] include(::String) at ./sysimg.jl:14
[5] anonymous at ./<missing>:2
while loading /home/spg/.julia/v0.6/TensorFlow/src/ops.jl, in expression starting on line 119
while loading /home/spg/.julia/v0.6/TensorFlow/src/TensorFlow.jl, in expression starting on line 184
ERROR: Failed to precompile TensorFlow to /home/spg/.julia/lib/v0.6/TensorFlow.ji.
Stacktrace:
[1] compilecache(::String) at ./loading.jl:703
[2] _require(::Symbol) at ./loading.jl:490
[3] require(::Symbol) at ./loading.jl:398

Following this link, run Pkg.update()

Related

TFlite Model Maker returns "Trying to decode BMP format using a wrong op" for a bunch of jpg images

I'm working off this basic tutorial https://www.tensorflow.org/lite/tutorials/model_maker_image_classification on image classification using Tensorflow lite. However, the image_classifier.create() returns the following error:
InvalidArgumentError: Trying to decode BMP format using a wrong op. Use `decode_bmp` or `decode_image` instead. Op used: DecodePng
[[{{node cond/DecodePng}}]]
[[IteratorGetNext]] [Op:__inference_train_function_11083]
Function call stack:
train_function -> train_function
I'm training the model using data from http://web.mit.edu/torralba/www/indoor.html. I've verified that there are no bitmap images in the dataset.
I'm on Python version 3.9.7 and tflite-model-maker version 0.3.4.
How might I solve this problem?
Thanks in advance.
It maybe path or header format, I had download and trying you may specific new header of the file < BM6f > OR < JFIF >
2 root error(s) found.
(0) INVALID_ARGUMENT: Trying to decode BMP format using a wrong op. Use `decode_bmp` or `decode_image` instead. Op used: DecodePng
[[{{node cond/DecodePng}}]]
[[IteratorGetNext]]
[[IteratorGetNext/_4]]
(1) INVALID_ARGUMENT: Trying to decode BMP format using a wrong op. Use `decode_bmp` or `decode_image` instead. Op used: DecodePng
[[{{node cond/DecodePng}}]]
[[IteratorGetNext]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_11154]

theano.function() throws up a long exception in Colab

I am using Google Colab to run the BinaryNet Neural Network implemented using theano by the authors of the original paper here: https://github.com/MatthieuCourbariaux/BinaryNet
When I run the following line from /Train-time/mnist.py (line 199):
train_fn = theano.function([input, target, LR], loss, updates=updates)
Colab throws up this error:
You can find the C code in this temporary file:
/tmp/theano_compilation_error_5_e2lq4v library
inux-gnu/bits/libc-header-start.h:33, is not found. library
inux-gnu/7/include-fixed/limits.h:194, is not found. library
inux-gnu/7/include-fixed/syslimits.h:7, is not found. library
inux-gnu/7/include-fixed/limits.h:34, is not found. library
inux-gnu/bits/mathcalls.h:298:1: is not found. library
inux-gnu/bits/mathcalls.h:298:1: is not found. library
inux-gnu/bits/libc-header-start.h:33, is not found. library
inux-gnu/7/include-fixed/limits.h:194, is not found. library
inux-gnu/7/include-fixed/syslimits.h:7, is not found. library
inux-gnu/7/include-fixed/limits.h:34, is not found. library
inux-gnu/bits/mathcalls.h:298:1: is not found. library
inux-gnu/bits/mathcalls.h:298:1: is not found.
Exception: ('The following error happened while compiling the node',
Elemwise{Composite{(i0 * (i1 + (i0 * round3(clip(i2, i3, i4)))) *
i5)}}[(0, 2)](TensorConstant{(1, 1) of 2.0}, TensorConstant{(1, 1) of
-1.0}, Elemwise{Composite{(i0 * (i1 + (i2 * i3 * i4) + i5))}}.0, TensorConstant{(1, 1) of 0}, TensorConstant{(1, 1) of 1},
Elemwise{Composite{Cast{float64}(LT(i0, i1))}}[(0, 0)].0), '\n',
"Compilation failed (return status=1):
/root/.theano/compiledir_Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic-x86_64-3.6.9-64/tmp9q80fef3/mod.cpp:932:2:
warning: character constant too long for its type. ['V15_tmp2'] =
round(['V15_tmp1']);. ^~~~~~~~~~.
/root/.theano/compiledir_Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic-x86_64-3.6.9-64/tmp9q80fef3/mod.cpp:932:23:
warning: character constant too long for its type. ['V15_tmp2'] =
round(['V15_tmp1']);. ^~~~~~~~~~.
/root/.theano/compiledir_Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic-x86_64-3.6.9-64/tmp9q80fef3/mod.cpp:1054:2:
warning: character constant too long for its type. ['V15_tmp2'] =
round(['V15_tmp1']);. ^~~~~~~~~~.
/root/.theano/compiledir_Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic-x86_64-3.6.9-64/tmp9q80fef3/mod.cpp:1054:23: warning: character constant too long for its type. ['V15_tmp2'] =
round(['V15_tmp1']);. ^~~~~~~~~~.
/root/.theano/compiledir_Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic-x86_64-3.6.9-64/tmp9q80fef3/mod.cpp: In member function ‘in...
I used this to install theano and lasagne:
!pip install --upgrade https://github.com/Theano/Theano/archive/master.zip
!pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip
I am using the exact same code as in the github repo with the only difference being that I used keras to import the mnist dataset instead of pylearn2
Could someone please help me figure out why this is happening? Thank you!
EDIT
I ran my code in python 2.7 and it worked! This question deals with using python 2 in Colab.

np.matmul() inside tf.py_func() throws SIGBUS error

I am seeing a fatal error from matrix multiplication inside a py_func call.
In the py_func call I am multiplying a tensor with a set of 3D coordinates by a rotation matrix. This reproduces the error:
x = np.matmul(np.ones([640*480, 3]), np.eye(3))
When running outside a TF session this works with no problem, but inside the session when called via py_func I get
Process finished with exit code 138 (interrupted by signal 10: SIGBUS)
Trying different tensor sizes I see that for a shape (29000,3) the line works, and for (29200,3) it fails.
I am using TensorFlow-1.12.0.
What could cause this issue and how can I resolve it?

Is Tensor Flow compatible with Julia 0.6.4?

So I have a project in my machine learning class and we are using Julia as our programming language. We can use any packages we want to build neural networks but I can't seem to get Tensor Flow to test correctly. Pkg.add("TensorFlow") works seemingly fine but here is the output for Pkg.test("TensorFlow")
julia> Pkg.test("TensorFlow")
INFO: Testing TensorFlow
ERROR: LoadError: LoadError: could not load library "C:\Users\Ryan .LAPTOP-
KJUJGIC7\.julia\v0.6\TensorFlow\src\..\deps\usr\bin\libtensorflow"
The specified module could not be found.
Stacktrace:
[1] dlopen(::String, ::UInt32) at .\libdl.jl:97
[2] TensorFlow.Graph() at C:\Users\Ryan .LAPTOP- KJUJGIC7\.julia\v0.6\TensorFlow\src\core.jl:21
[3] include_from_node1(::String) at .\loading.jl:576
[4] include(::String) at .\sysimg.jl:14
[5] include_from_node1(::String) at .\loading.jl:576
[6] include(::String) at .\sysimg.jl:14
[7] process_options(::Base.JLOptions) at .\client.jl:305
[8] _start() at .\client.jl:371
while loading C:\Users\Ryan .LAPTOP-KJUJGIC7\.julia\v0.6\TensorFlow\test\..\examples\logistic.jl, in expression starting on line 22
while loading C:\Users\Ryan .LAPTOP-KJUJGIC7\.julia\v0.6\TensorFlow\test\runtests.jl, in expression starting on line 6
=================================================[ ERROR: TensorFlow ]==================================================
failed process: Process(`'C:\Users\Ryan .LAPTOP-KJUJGIC7\AppData\Local\Julia-0.6.4\bin\julia.exe' -Cgeneric '-JC:\Users\Ryan .LAPTOP-KJUJGIC7\AppData\Local\Julia-0.6.4\lib\julia\sys.dll' --compile=yes --depwarn=yes --check-bounds=yes --code-coverage=none --color=yes --compilecache=yes 'C:\Users\Ryan .LAPTOP-KJUJGIC7\.julia\v0.6\TensorFlow\test\runtests.jl'`, ProcessExited(1)) [1]
========================================================================================================================
ERROR: TensorFlow had test errors
I'm running Julia Version 0.6.4 on Windows 10; if there's a way to resolve this error or a workaround I'd love some suggestions.
TensorFlow.jl does not support Windows.
You have two options:
(1) Try using TensorFlow via PyCall.jl:
using Conda
Conda.runconda("install -c conda-forge tensorflow")
(2) Use Flux.jl instead

Trouble Registering Function With Spark-SQL using PySpark

I'm getting an error when I try to register a function with Spark - SQL that I created with the Python API.
First, I train my logistic regression model:
from pyspark.mllib.regression import LinearRegressionWithSGD
LRM = LinearRegressionWithSGD()
linear_model = LRM.train(transformed_data_scaled, intercept = True)
I know the linear model is trained successfully because I get the following:
print 'Model Coefficients:', linear_model.weights
print 'Model Intercept:', linear_model.intercept
Model Coefficients: [-82.6194271643,2381.06882039,-65.0826814456,1.70454845719,-75.5970986012,-67.5109145931]
Model Intercept: 2081.56222548
Next, I create a function by using the following code:
from pyspark.mllib.linalg import Vectors
def predict(a,b,c,d,e,f):
return linear_model.predict(Vectors.dense([a,b,c,d,e,f]))
I know this function is working correctly because I can test it as follows:
> predict(1,2,3,4,5,6)
Out[44]: 5789.599608026406
Lastly, I register the function I created with Spark-SQL as follows:
> sqlContext.registerFunction("predict", predict)
When I try to use this command in SQL, I get the following error:
%sql select predict(1,2,3,4,5,6)
Error in SQL statement: java.lang.RuntimeException:
org.apache.spark.SparkException: Job aborted due to stage failure:
Task 0 in stage 22181.0 failed 4 times, most recent failure: Lost task
0.3 in stage 22181.0 (TID 536610, ip-10-0-162-160.ec2.internal): net.razorvine.pickle.PickleException: expected zero arguments for
construction of ClassDict (for numpy.dtype)
I found the answer. When you call the registerFunction, you have to provide the third argument, which is the datatype.
registerFunction(name, f, returnType=StringType)
Note how the third parameter is the datatype with a default of string. I neglected to pass this parameter so I was getting the error.