birth_forecast_reverse = scaler.reverse_transform(birth_reshape)
But i have git the erro like below
AttributeError Traceback (most recent call last)
in ()
----> 1 birth_forecast_reverse = scaler.reverse_transform(birth_reshape)
AttributeError: 'MinMaxScaler' object has no attribute 'reverse_transform'
There is the typo in the method name. Instead reverse_transform you should use inverse_transform. Here is the link for the documentation.
Related
I'm playing with this lua link: http://underpop.free.fr/l/lua/docs/programming-in-lua-first-edition.pdf and get confused about the rename function. I tried it out and only to get an error message as the following.
> rename{old = "temp.lua", new = "temp1.lua"}
stdin:1: attempt to call global 'rename' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: in ?
> os.rename{old = "temp.lua", new = "temp1.lua"}
stdin:1: bad argument #1 to 'rename' (string expected, got table)
stack traceback:
[C]: in function 'rename'
stdin:1: in main chunk
[C]: in ?
Moreover, I'm learning Lua because I'm reading a piece of code, which is written in Lua. I do not think the link provided above, programming in lua first edition, is a good tutorial. I've also found a reference menu, but do not quite like it also. Can anyone please provide a good tutorial based on your opinion?
EDIT: I tried it again with the following code:
> function rename(arg)
>> return os.rename(arg.old, arg.new)
>> end
>
> rename{old = "temp.lua", new = "temp1.lua"}
It works this time.
stdin:1: attempt to call global 'rename' (a nil value)
This error message tells you exactly what the problem is.
It is caused by this line:
rename{old = "temp.lua", new = "temp1.lua"}
rename is a nil value. Hence Lua does not know what to do if you call it. In order to avoid this error you have to define rename as a callable variable like.
Let me just quote the tutorial you do not find good.
rename{old="temp.lua", new="temp1.lua"}
Accordingly, we define rename with only one parameter and get the
actual arguments from this parameter:
function rename (arg)
return os.rename(arg.old, arg.new)
end
I have an llvm::CallInst *i, representing this call (taken from *.ll file):
%tmp3 = call i64 #__fdget(i32 %tmp) #5
How do I extract the returned value name (%tmp3 here)?
Thanks!
llvm::Value::getName contains instruction name.
llvm::StringRef name = i->getName();
I tried to add a function to the Module.lua abstract file in the Torch package called nn, but my main program does not find it.
Suppose my function is simply:
function printTry()
print("printTry()");
end
I added this function at the end of the Module.lua file and I was supposed to use it in my Torch terminal:
require 'nn';
perceptron = nn.Module();
perceptron:printTry()
But the system generates:
string "perceptron.printTry();"]:1: attempt to call field 'printTry' (a nil value)
stack traceback:
[string "perceptron.printTry();"]:1: in main chunk
[C]: in function 'xpcall'
/home/davide/torch/install/share/lua/5.1/trepl/init.lua:668: in function 'repl'
...vide/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x004064d0
Probably the system is not aware of this new function that I added... what should I do to use this new method?
Use torch.getmetatable:
require 'nn'
torch.getmetatable('nn.Module').printTry = function() print('PrintTry') end
perceptron = nn.Sequential()
perceptron:printTry()
You simply defined a global function printTry, but you call it as a method on perceptron. You need to define it as a field of Module (in that Module.lua file, assuming this is what nn.Sequential returns):
function Module:printTry()
print("printTry()")
end
Let's say that I call some functions indirectly, via a variable. For example:
obj = {
on_init = function()
print "hello."
end,
on_destroy = function()
print "bye."
end,
on_do_something = function()
print "doing something."
error("Hi de hi, hi de ho!")
end,
}
local event = "do_something"
local func = obj["on_" .. event]
func()
All works fine.
However, the problem is that when the called function raises an exception (as in the code above) the error message isn't quite clear. It is thus:
lua: test.lua:13: Hi de hi, hi de ho!
stack traceback:
[C]: in function 'error'
test.lua:13: in function 'func'
test.lua:20: in main chunk
It says "in function 'func'". I'd prefer it to say "in function 'on_do_something'" instead.
I'd imagine this scenario to be very common. Is there a solution for this?
I tried calling the function thus:
obj["on_" .. event]()
But then the error message says "in function '?'", which isn't helpful either.
(I tried this code on Lua 5.1, 5.2 and LuaJIT without notable differences.)
This is a limitation of the heuristics used by Lua to provide names for functions.
In Lua, all functions are anonymous. A given function can be the value of several variables: global, local, and table fields. The Lua debug system, which is used in error handling, tries to find a reasonable name for a value based on where it came from by looking into the bytecode being executed.
See
Why is 'name' nil for debug.getinfo(1).
You have a few options. The debug module will try to produce something useful. For instance, you might be able to get the file name and line number where it was defined, if this is your own code. See
http://www.lua.org/pil/23.1.html for the list of what is available via debug module. Or, you might be able to define the functions in the module, then add them to the table:
-- module something
function a()
...
end
tt = {
fn1 = a,
...
}
Depending on where you trap the error (error handler installed via debug hook?), you could check if filename is the module where your table of functions is defined, and if it is, then use the debug module to print appropriate info based on your table structure etc; if it is not, just print the default traceback etc.
I have some confusion debugging some simple app that uses the Web Audio API.
In the developer console I can do something like this:
var ctx = new webkitAudioContext(),
osc = ctx.createOscillator();
osc.connect(ctx.destination);
osc.start(0);
Trying to get this to work with Dart yields the following errors when I try it like this:
AudioContext ctx = new AudioContext();
OscillatorNode osc = ctx.createOscillator();
osc.connect(ctx.destination);
osc.start(0);
//Dart2JS: Uncaught TypeError: Object #<OscillatorNode> has no method 'connect$1'
//DartVM: Class 'OscillatorNode' has no instance method 'connect' with matching
arguments. NoSuchMethodError: incorrect number of arguments passed to method
named connect' Receiver: Instance of 'OscillatorNode'
Stepping through I found that there are two kinds of implementations to the connect method. So I tried to add an extra second param and since I can not really wrap my head around why it needs an int named "output", thinking maybe it is for volume I decided on the value 1 but that yields:
//Dart2JS: Uncaught Error: IndexSizeError: DOM Exception 1 flexsynth.html_bootstrap.dart.js:8698 $.main flexsynth.html_bootstrap.dart.js:8698 $$._IsolateContext.eval$1flexsynth.html_bootstrap.dart.js:565 $.startRootIsolate flexsynth.html_bootstrap.dart.js:7181 (anonymous function)
//DartVM: "Dart_IntegerToInt64 expects argument 'integer' to be non-null."
Here is where I can't figure out what to do, I think the argument is not null, it is 1.
Googling the errors only leads me to the actual Dart source code.
Is there any place that explains how to work with the dart:web_audio? What am I doing wrong?
This is because the underlying implementation seems to require the parameter input, despite it being an optional parameter. This code will work:
AudioContext ctx = new AudioContext();
OscillatorNode osc = ctx.createOscillator();
osc.connect(ctx.destination, 0, 0);
osc.start(0);
This is a known bug, you can star it here: https://code.google.com/p/dart/issues/detail?id=6728