Maple isnt executing function but prints function term - function

Im using maple Im in worksheetmode I tried using Maple Input and 2D Input and I want to transpose my Matrix A:
A := `<|>`(`<,>`(1, .5, -2), `<,>`(.5, 9/4+b, 5+3*b), `<,>`(-2, 5+3*b, 18+9*b+4*a));
B:= Transpose(A);
When I exectute the sheet I dont get the translated values, there are the same as the input. So my matrix looks like the same as my input matrix plus the function term.
You can see a picture in the following link: Why arent the functions executed?
Meanwhile B:=A^+ is doing it the right way and I get a transposed Matrix. But also other functions only return the function body instead the needed values...

If you are using 2D Input mode (the default) then the extra space you've got between Transpose and the bracketed (B) is interpreted as multiplcation. Get rid of such a space.
Also, either load the package at the start of your document like,
with(LinearAlgebra):
before calling the Transpose command from that package, or call it with it's full name like,
LinearAlgebra:-Transpose(B);

Related

Why the ouput of nn.Embeddings(vocab_size, dim) chnages on re-running the code for same input string?

I am trying to understand how word embeddings are generated, I've been reading that 1-hot encoded vector is used and it servers as a lookup table but, I want to print that and see, how can I do that. When I am doing the following:
self.embeddings = nn.Embedding(vocab_size, dim)
print('embed',self.embeddings.weight)
I am getting different results when I re-run the code for same input string/vocab_size and same dim.
I want to know why this happens and how are those weight values calulated? What equation/fucntions is used to get these values? Is any function like softmax etc used to get the weights?

Can I call a function to solve for different variables?

I have a function where I want to solve for many variables separately, do I have to write down the function every time in terms of the other variable?
x,xG,xR
y = e.^tan(x.^2)+cos.^2(x);
yG = e.^tan(xG.^2)+cos.^2(xG);
First you cannot write an expression like cos.^2(x). If x is a single variable (ie x=pi) you could write either cos(x)^2 or cos(x^2). If x is a vector (a column vector might be x=[3;4;pi] and a row vector might be x=[3,4,pi], then you might write cos(x).^2 or cos(x.^2). The role of the period (.) in octave is explained here: https://octave.org/doc/v4.0.3/Arithmetic-Ops.html
Another issue has to do with understanding the difference between an expression: x=e^tanh(y); and a function. The later is a separate chunk of code that can be invoked from anywhere in your program.
Consider this simple example
1;
function y=myfunc(x)
y=exp(tanh(x));
endfunction
## main program
xxx=pi/3;
yyy=myfunc(xxx);
printf('%7.3f %7.3f\n',xxx,yyy)
y=exp(tanh(pi/3))
comments: The '1' in the first line tells Octave that there is more to the script than just the following function: the main program has to be interpreted as well. The function line specifies that inside the function, the input will be called x and the output y, so when my function is called from main, the input is xxx(=pi/2) and the output is yyy. The last line in this tiny script is an expression that does the same thing as the function. Note that since I didn't include a semi-colon at the end of that line the result is printed out
I suggest you play with this for a while, then if you have more questions, ask them in a new question.

Provide mean pixel values to Caffe's python classify.py

I'd like to test a Caffe model with the Python wrapper:
python classify.py --model_del ./deploy.prototxt --pretrained_model ./mymodel.caffemodel input.png output
Is there a simple way to give mean_pixel values to the python wrapper? It seems to only support a mean_file argument?
The code makes use of args.mean_file variable to read a numpy format data to a variable mean. The easiest method will be to bring on a new parser argument named args.mean_pixel which has a single mean value, store it a mean_pixel variable, then create an array called mean which has the same dimensions as that of input data and copy the mean_pixel value to all the elements in the array. The rest of the code will function as normal.
parser.add_argument(
"--mean_pixel",
type=float,
default=128.0,
help="Enter the mean pixel value to be subtracted."
)
The above code segment will try to take a command line argument called mean_pixel.
Replace the code segment:
if args.mean_file:
mean = np.load(args.mean_file)
with:
if args.mean_file:
mean = np.load(args.mean_file)
elif args.mean_pixel:
mean_pixel = args.mean_pixel
mean = np.array([image_dims[0],image_dims[1],channels]) #where channels is the number of channels of the image
mean.fill(mean_pixel)
This will make the code to pick the mean_pixel value passed on as an argument, if mean_file is not passed as an argument. The above code will create an array with the dimensions as that of the image and fill it with the mean_pixel value.
The rest of the code needn't be changed.

Run function based on cell value

I want to run a function if a cell value is "Smartphone". I have tried a few ways of writing this but it keeps failing and can not figure out the right way to type it.
function ifTest(event){
if(SpreadsheetApp.getActiveSheet().getRange("B11").getValue() = "Smartphone"){ // mobile phone check
emailMobileRequired(); // Launches the script
}
}
You need to use two equal signs instead of one to compare two values and test for equality. (read more: http://www.w3schools.com/js/js_comparisons.asp)
In javascript one equal sign is an assignment operator. The expression result on the right is assigned to the variable on the left. (read more: http://www.w3schools.com/js/js_operators.asp)

Matrix contains values but still symbolic - Matlab

I have a matrix that is outputted like this:
maximums =
[ -9.9043877608991468201413092380493, 426.34796945271797204125533010993]
[ 9.3758615553048990076305298649689, 441.87005169359418197397861057075]
But when I try and run any commands on it, I get an error saying that this matrix is still symbolic. I don't understand since it's just numeric values. Is there anyway of making this matrix outputted used by normal functions of Matlab?
To get this matrix, I did calculate derivatives of a symbolic equation and then evaluate. But I'd like to run functions on this output.
Thanks!
EDIT (Here's an example of the command/error):
[maxValue, rowIdx] = max(maximums(:,2),[],2)
Undefined function 'max' for input arguments of type 'sym'.
Since your matrix is symbolic, you have to convert it to numeric first:
maximums = double(maximums)
You have to convert it:
maximus=double(maximus)