NeuralTalk2 Error - deep-learning

I am getting the following output on trying to run neuraltalk2
parag#parag:~/MyHome/neuraltalk2/neuraltalk2-master$ th eval.lua -model /home/parag/MyHome/neuraltalk2/ -image_folder /home/parag/MyHome/neuraltalk2/images/ -num_images -1 -gpuid -1
/home/parag/torch/install/bin/luajit: /home/parag/torch/install/share/lua/5.1/torch/File.lua:199: read error: read 0 blocks instead of 1 at /home/parag/torch/pkg/torch/lib/TH/THDiskFile.c:314
stack traceback:
[C]: in function 'readInt'
/home/parag/torch/install/share/lua/5.1/torch/File.lua:199: in function 'readObject'
/home/parag/torch/install/share/lua/5.1/torch/File.lua:325: in function 'load'
eval.lua:69: in main chunk
[C]: in function 'dofile'
...arag/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x00405d70
parag#parag:~/MyHome/neuraltalk2/neuraltalk2-master$
What is going wrong here?

My command was incomplete. The full path of model including the model name is to be given in the command as follows:
$ th eval.lua -model /home/parag/MyHome/neuraltalk2/model_id1-501-1448236541.t7_cpu.t7 -image_folder /home/parag/MyHome/neuraltalk2/images/ -num_images -1 -gpuid -1
This solved the issue for me!

Related

standard input file is closed stack traceback error when looping a function to open a file in lua

1local function readfile(name)
2 io.input(name)
3 local file = io.read("*all")
4 io.close(io.input())
5 return(file)
6end
31repeat
32 local input = io.read()
33 if string.sub(input, 1, 1) == ("#") then do
34 local ninput = string.sub(input, 2, 100)
35 print(readfile(ninput))
36 end
37end
38until input == ("stop")
i get this error every time i try to run the code. it runs once then errors out afterward and help is much apreciated.
lua:32: standard input file is closed
stack traceback:
[C]: in function 'io.read'
testing.lua:32: in main chunk
[C]: in ?
Read files with io.open to avoid touching stdin.
local function readfile(name)
local f = assert(io.open(name))
local content = f:read("*all")
f:close()
return content
end

cythonize under py3.6.4 Cannot convert 'basestring' object to bytes implicitly. This is not portable

This code snippet works just fine under python 3.6.4 but is triggering a portability issue when present in .pyx files. I could use some help figuring out how to best format python 3.5.1+ bytes in Cython.
EDIT: Changing this in light of DavidW's comment.
Following works in python 3.6.4 under ipython
def py_foo():
bytes_1 = b'bytes 1'
bytes_2 = b'bytes 2'
return b'%(bytes_1)b %(bytes_2)b' % {
b'bytes_1': bytes_1,
b'bytes_2': bytes_2}
As hoped this results in:
print(py_foo())
b'bytes 1 bytes 2'
Using cython with the only changes to the code being the name of the function, a return type declared, and declaring the two variables.
%load_ext Cython
# Cython==0.28
followed by:
%%cython
cpdef bytes cy_foo():
cdef:
bytes bytes_1, bytes_2
bytes_1 = b'bytes 1'
bytes_2 = b'bytes 2'
return b'%(bytes_1)b %(bytes_2)b' % {
b'bytes_1': bytes_1,
b'bytes_2': bytes_2}
Results in:
Error compiling Cython file:
....
return b'%(bytes_1)b %(bytes_2)b' % {
^
..._cython_magic_b0aa5be86bdfdf75b98df1af1a2394af.pyx:7:38: Cannot convert 'basestring' object to bytes implicitly. This is not portable.
-djv
I'm not sure if this is a useful answer or just a more detailed diagnosis, but: the issue is with the return type. If you do:
cpdef cy_foo1(): # no return type specified
# everything else exactly the same
then it's happy. If you do
cpdef bytes cy_foo2():
# everything else the same
return bytes(b'%(bytes_1)b %(bytes_2)b' % {
b'bytes_1': bytes_1,
b'bytes_2': bytes_2})
then it's happy. If you do
def mystery_function_that_returns_not_bytes():
return 1
cpdef bytes cy_foo3():
return mystery_function_that_returns_not_bytes()
then it compiles happily but gives a runtime exception (as you would expect)
The issue seems to be that it knows bytes % something returns a basestring but it isn't confident that it returns bytes and isn't prepared to leave it until runtime to try (unlike the cases where it's totally sure, or completely unsure, when it will leave it until runtime).
The above examples show a couple of ways of working round it. Personally, I'd just remove the return type - you don't get a lot of benefit from typing Python objects such as bytes anyway. You should probably also report this as a bug to https://github.com/cython/cython/issues

Lua-cjson -> require("cjson") successful, then errors when calling cjson.encode

I'm trying to encode/decode JSON in Lua using CJSON. I downloaded lua-cjson using Luarocks (http://www.kyne.com.au/~mark/software/lua-cjson-manual.html).
In the Lua interpreter, I'm using an example from the cjson manual:
> local cjson = require "cjson"
> value = { true, { foo = "bar" } }
> json_text = cjson.encode(value)
stdin:1: attempt to index a nil value (global 'cjson')
stack traceback:
stdin:1: in main chunk
[C]: in ?
I know that cjson is being found, because if I were to do ' require "foobar" ', Lua would error. It's just not able to use the module. Any help would be appreciated.
Each line in an interactive session is a separate chunk. So, the local variable created in line 1 no longer exists in the next lines. Note how the error message mentions a global variable. Try removing local.

Error in fromJSON(paste(raw.data, collapse = "")) : unclosed string

I am using the R package rjson to download weather data from Wunderground.com. Often I leave the program to run and there are no problems, with the data being collected fine. However, often the program stops running and I get the following error message:
Error in fromJSON(paste(raw.data, collapse = "")) : unclosed string
In addition: Warning message:
In readLines(conn, n = -1L, ok = TRUE) :
incomplete final line found on 'http://api.wunderground.com/api/[my_API_code]/history_20121214pws:1/q/pws:IBIRMING7.json'
Does anyone know what this means, and how I can avoid it since it stops my program from collecting data as I would like?
Many thanks,
Ben
I can recreate your error message using the rjson package.
Here's an example that works.
rjson::fromJSON('{"x":"a string"}')
# $x
# [1] "a string"
If we omit a double quote from the value of x, then we get the error message.
rjson::fromJSON('{"x":"a string}')
# Error in rjson::fromJSON("{\"x\":\"a string}") : unclosed string
The RJSONIO package behaves slightly differently. Rather than throwing an error, it silently returns a NULL value.
RJSONIO::fromJSON('{"x":"a string}')
# $x
# NULL

TCL/TK error message doesn't help. Can some help me, please

I am new to TK and I think the error message that I am getting is with TK. Here is the error message:
unknown option "-state"; must be one of -background, -bd, -bg, -borderwidth, -columnbd, -columnborderwidth, -columnrelief, -cursor, -exportselection, -fg, -fillcolumn, -font, -foreground, -height, -highlightbackground, -highlightcolor, -highlightthickness, -labelanchor, -labelbackground, -labelbd, -labelbg, -labelborderwidth, -labelfg, -labelfont, -labelforeground, -labelheight, -labelimage, -labelrelief, -labels, -relief, -resizablecolumns, -selectbackground, -selectborderwidth, -selectcommand, -selectforeground, -selectmode, -setgrid, -takefocus, -width, -xscrollcommand or -yscrollcommand
errorInfo trace:
unknown option "-state"; must be one of -background, -bd, -bg, -borderwidth, -columnbd, -columnborderwidth, -columnrelief, -cursor, -exportselection, -fg, -fillcolumn, -font, -foreground, -height, -highlightbackground, -highlightcolor, -highlightthickness, -labelanchor, -labelbackground, -labelbd, -labelbg, -labelborderwidth, -labelfg, -labelfont, -labelforeground, -labelheight, -labelimage, -labelrelief, -labels, -relief, -resizablecolumns, -selectbackground, -selectborderwidth, -selectcommand, -selectforeground, -selectmode, -setgrid, -takefocus, -width, -xscrollcommand or -yscrollcommand
while executing
"::mclistbox::Canonize $w option [lindex $args 0]"
(procedure "::mclistbox::WidgetProc" line 211)
invoked from within
"::mclistbox::WidgetProc .autoQuote.reportInfoTab.f.tit76.f.mcl84 cget -state"
("eval" body line 1)
invoked from within
"eval ::mclistbox::WidgetProc {.autoQuote.reportInfoTab.f.tit76.f.mcl84} $command $args"
(procedure ".autoQuote.reportInfoTab.f.tit76.f.mcl84" line 1)
invoked from within
"$w cget -state"
(procedure "tk::ListboxBeginSelect" line 18)
invoked from within
"tk::ListboxBeginSelect [::mclistbox::convert .autoQuote.reportInfoTab.f.tit76.f.mcl84.framecol1.listbox -W] [[::mclistbox::convert .autoQuote.reportIn..."
invoked from within
"if {[winfo exists [::mclistbox::convert .autoQuote.reportInfoTab.f.tit76.f.mcl84.framecol1.listbox -W]]} {
tk::ListboxBeginSelect [::mclistbox::conve..."
(command bound to event)
This isn't my code but it looks like it's going the Widget library. I have found the routine 'widgetProc' and it appears to have a '-state' switch. I am just drawing a blank right now.
Here is my environment:
Windows 7 Enterprise SP1.
tcl version: 8.5.11.1
bwidgets 1.95
iwidgets 4.0.1
tcllib 1.14
The error isn't caused by widgetProc, but rather by ::mclistbox::Canonize. Now unfortunately, I'm not familiar with it but a quick Google search shows this result with similar lack of resolution. However, the dates on the posting would lead me to make an optimistic suggestion that you upgrade to a more recent version if possible. If that is not possible, maybe you could show us the code you're using - it maybe possible that the way you're calling it is triggering the error.
I found a quick workaround. Not sure if it's entirely correct or not, but it worked for me.
Add the following under line 77 ( which should be "array set widgetOptions [list \" )
-state {State State} \
Would provide a diff, but it's such a simple fix I don't feel that it warrants it.