plateform stringclasses 1
value | repo_name stringlengths 13 113 | name stringlengths 3 74 | ext stringclasses 1
value | path stringlengths 12 229 | size int64 23 843k | source_encoding stringclasses 9
values | md5 stringlengths 32 32 | text stringlengths 23 843k |
|---|---|---|---|---|---|---|---|---|
github | hipercog/ctap-master | rapca.m | .m | ctap-master/dependencies/LIBRA/rapca.m | 14,125 | utf_8 | a9d028d28513a15ecb445199cf72f808 | function result=rapca(data,varargin);
%RAPCA is a 'Reflection-based Algorithm for Principal Components Analysis'.
% It is resistant to outliers in the data. The robust loadings are computed
% using projection-pursuit techniques and reflections.
% Therefore RAPCA can be applied to both low and high-dimensional d... |
github | hipercog/ctap-master | cvMcd.m | .m | ctap-master/dependencies/LIBRA/cvMcd.m | 4,455 | utf_8 | 4d75e2eefae1ec94c7abd3c74561b184 | function result = cvMcd(data,kmax,resMCD,h)
%CVMCD calculates the robust cross-validated PRESS (predicted residual error sum of squares)
% curve for the MCD method in a fast way.
%
% Input arguments:
% data : the full data set
% kmax : the maximal number of components to be considered (mostly kmax = p... |
github | hipercog/ctap-master | choosebox.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/choosebox.m | 14,046 | utf_8 | 9c8b3689e8901b8bf74c8764a2a1e6c5 | function [selection,value] = choosebox(varargin)
%CHOOSEBOX Two-listed item selection dialog box.
% [SELECTION,OK] = CHOOSEBOX('ListString',S) creates a modal dialog box
% which allows you to select a string or multiple strings from a list.
% Single or multiple strings can be transferred from a base list to... |
github | hipercog/ctap-master | findpeaks.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/findpeaks.m | 6,142 | utf_8 | 9641481cb7ddbef643caad46459cc385 | function P=findpeaks(x,y,SlopeThreshold,AmpThreshold,smoothwidth,peakgroup,smoothtype)
% function P=findpeaks(x,y,SlopeThreshold,AmpThreshold,smoothwidth,peakgroup,smoothtype)
% Function to locate the positive peaks in a noisy x-y time series data
% set. Detects peaks by looking for downward zero-crossings
% in th... |
github | hipercog/ctap-master | tableGUI.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/tableGUI.m | 20,832 | utf_8 | 3d7c45df049aa2aec00c7c4da4d7e285 | function out = tableGUI(varargin)
% TABLEGUI - Spreadsheet like display and edition of a generic 2D array. By generic it is
% mean that the array can be a numeric MxN matrix or a MxN cell array (with mixed
% number and text strings). This function imitates the table cells with edit boxes
% which may become ... |
github | hipercog/ctap-master | fastlts.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/fastlts.m | 53,220 | utf_8 | f7d49dca489a79a5f31e6ff7492f2dad | function [res,raw] = fastlts(x,y,options)
% version 22/12/2000, revised 19/01/2001, 30/01/2003
% last revision: 20/04/2006
%
% FASTLTS carries out least trimmed squares (LTS) regression, introduced in
%
% Rousseeuw, P.J. (1984), "Least Median of Squares Regression,"
% Journal of the American Statistical Associatio... |
github | hipercog/ctap-master | parseAttributes.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/parseAttributes.m | 589 | utf_8 | 2ae775b1b5927b596fe272ac0fea92a6 | % ----- Subfunction PARSEATTRIBUTES -----
function attributes = parseAttributes(theNode)
% Create attributes structure.
attributes = [];
if theNode.hasAttributes
theAttributes = theNode.getAttributes;
numAttributes = theAttributes.getLength;
allocCell = cell(1, numAttributes);
attributes = struct(... |
github | hipercog/ctap-master | rms.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/rms.m | 1,487 | utf_8 | caed03c1176995df93b651a10ff00d63 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Calculates exponential averaged RMS of a signal using the specified
% windowlength as the time constant.
%
% USAGE: y = rms(signal, windowlength, downsampling)
%
% SIGNAL is a 1-D data vector. WINDOWLENGTH is an integer length
% corresponding to the time constant. DO... |
github | hipercog/ctap-master | parseChildNodes.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/parseChildNodes.m | 583 | utf_8 | 1cb8615401b1c6449d0294c0a05f726e | % ----- Subfunction PARSECHILDNODES -----
function children = parseChildNodes(theNode)
% Recurse over node children.
children = [];
if theNode.hasChildNodes
childNodes = theNode.getChildNodes;
numChildNodes = childNodes.getLength;
allocCell = cell(1, numChildNodes);
children = struct( ... |
github | hipercog/ctap-master | makeStructFromNode.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/makeStructFromNode.m | 500 | utf_8 | 38edf7a5003b0938e20140817de9497e | % ----- Subfunction MAKESTRUCTFROMNODE -----
function nodeStruct = makeStructFromNode(theNode)
% Create structure of node info.
nodeStruct = struct( ...
'Name', char(theNode.getNodeName), ...
'Attributes', parseAttributes(theNode), ...
'Data', '', ... |
github | hipercog/ctap-master | genHyper.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/genHyper.m | 59,799 | utf_8 | 58995429be4800041cea16324b9e4d29 | function [pfq]=genHyper(a,b,z,lnpfq,ix,nsigfig);
% function [pfq]=genHyper(a,b,z,lnpfq,ix,nsigfig)
% Description : A numerical evaluator for the generalized hypergeometric
% function for complex arguments with large magnitudes
% using a direct summation of the Gauss series.
% p... |
github | hipercog/ctap-master | selectdlg2.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/selectdlg2.m | 25,441 | utf_8 | 7e8830cfa390ac79a10590b021429a5a | function k = selectdlg2( cellItems, guiTitle, selMode, selDeft )
%selectdlg2 Generate a scrolled matrix of choices for user selection.
% Choice = selectdlg2(Itemlist) returns an index into Itemlist.
% Itemlist is cell array containing:
% a string cell vector of row titles (optional)
% a string ... |
github | hipercog/ctap-master | fastmcd.m | .m | ctap-master/dependencies/continuous_sound_and_vibrations_analysis/fastmcd.m | 64,671 | utf_8 | 2ddb328ab3001a09c73410b845385ec0 | function [res,raw]=fastmcd(data,options);
% version 22/12/2000, revised 19/01/2001,
% new reweighted correction factors and old cutoff 9/07/2001
% last revision 20/04/2006
%
% FASTMCD computes the MCD estimator of a multivariate data set. This
% estimator is given by the subset of h observations with smallest covar... |
github | sahildua2305/linguist-master | convert_variable.m | .m | linguist-master/samples/Matlab/convert_variable.m | 2,186 | utf_8 | 3d73feb0b3feaa01d8b434d83f275241 | function [name, order] = convert_variable(variable, output)
% Returns the name and order of the given variable in the output type.
%
% Parameters
% ----------
% variable : string
% A variable name.
% output : string.
% Either `moore`, `meijaard`, `data`.
%
% Returns
% -------
% name : string
% The variable name i... |
github | sahildua2305/linguist-master | create_ieee_paper_plots.m | .m | linguist-master/samples/Matlab/create_ieee_paper_plots.m | 34,238 | utf_8 | 3cf9c020f3fbd215ddc5182743c38bc8 | function create_ieee_paper_plots(data, rollData)
% Creates all of the figures for the IEEE paper.
%
% Parameters
% ----------
% data : structure
% A structure contating the data from generate_data.m for all of the bicycles
% and speeds for the IEEE paper.
% rollData : structure
% The data for a single bicycle at ... |
github | sahildua2305/linguist-master | plant.m | .m | linguist-master/samples/Matlab/plant.m | 2,087 | utf_8 | daf74d53d9253d37bd69d59c76021156 | function Yc = plant(varargin)
% function Yc = plant(varargin)
%
% Returns the system plant given a number.
%
% Parameters
% ----------
% varargin : variable
% Either supply a single argument {num} or three arguments {num1, num2,
% ratio}. If a single argument is supplied, then one of the six transfer
% functions ... |
github | ghananigans/fydp-tests-and-simulations-master | initial_prototype_sim.m | .m | fydp-tests-and-simulations-master/initial_prototype/initial_prototype_sim.m | 2,447 | utf_8 | a5d7a82b7f66f27af4b0397f2ed20eeb | %
% NAME: initial_prototype_sim
%
% DESCRIPTION: Runs a simulation for the intial prototype of FYDP Project,
% CommBlocker (reduce ambient noise at source).
%
% PARAMETERS:
% window_size (unsigned int)
% - Number of samples that will be fft-ed.
%
% RETURNS:
% N/A
%
function [] = initial_prot... |
github | poodarchu/ml-lab-master | test_nn_sigmoid_course.m | .m | ml-lab-master/机器学习实验课/实验二:神经网络/src/test_nn_sigmoid_course.m | 3,603 | utf_8 | cf2332598f74a9addf1ef6bc6d6c15a4 | function test_nn_sigmoid_course
% close all;
x = load('data/wdbc.txt'); y = load('data/wdbclabel.txt');
x = mapminmax(x', 0, 1)'; y = y - min(y);
% ?????
[param,model]=initParam(x);
% ??
model=trainNN(x,y,model,param);
% ??
[acc,output,label]=predictNN(x,y,model,param);
% ????
subplot(2,2,1);
tt=1:1:siz... |
github | karthikeyaparunandi/Control-and-Dynamics-Simulation-of-a-Trajectory-following-Quadrotor-UAV-master | plot_quad.m | .m | Control-and-Dynamics-Simulation-of-a-Trajectory-following-Quadrotor-UAV-master/plot_quad.m | 1,016 | utf_8 | 6bc9851853e0280e21589df49a5024b8 |
function plot_quad(phi,theta,psi,i,j,k)
axes('xlim',[-40,40],'ylim',[-40,40],'zlim',[-50,50]);
view(3);
grid on;
axis equal;
hold on;
xlabel('x');
ylabel('y');
zlabel('z');
%syms theta psi phi;
Rz=[cos(psi) sin(psi) 0;-sin(psi) cos(psi) 0;0 0 1];
Ry =[cos(theta) 0 -sin(theta);0 1 0;sin(theta) 0 cos(the... |
github | CG-F16-27-Rutgers/steersuite-rutgers-master | OptimizeAlgorithm.m | .m | steersuite-rutgers-master/steerstats/OptimizeAlgorithm.m | 18,321 | utf_8 | 7fb59d771036bda9ceac6cb8dd4ca3f4 |
% matlab -nodesktop -nosplash -r OptimizeAlgorithm
% matlab -nodesktop -nosplash -r "options.opts='steak'; options.ai='ppr'; options.cmaLogFilenamePrefix='CMA_PPR'; OptimizeAlgorithm(options)"
% matlab -nodesktop -nosplash -r "options.opts='steak'; options.ai='ppr'; options.cmaLogFilenamePrefix='data/optimization/CMA... |
github | rammanouil/LaplacianRegularizationHyper-master | Affinity_Thresh.m | .m | LaplacianRegularizationHyper-master/Supplementary_Functions/Affinity_Thresh.m | 592 | utf_8 | 8761ea3438e773cb771b1c16ca746940 |
function [A, xy] = Affinity_Thresh(h,N,r,dmin)
A = zeros(N,N);
D = zeros(N,N);
for i =1:N
ri = r(:,i);
D(i,i) = inf;
for j = i+1:N
rj = r(:,j);
D(i,j) = sum((ri - rj).^2); % +sum((rsi - rj).^2)*flag +sum((ri - rsj).^2)*flag ;
D(j,i) = D(i,j);
end
end
f... |
github | rammanouil/LaplacianRegularizationHyper-master | normrow.m | .m | LaplacianRegularizationHyper-master/Supplementary_Functions/normrow.m | 141 | utf_8 | 7e0616bf02536b9af8b136771849adbc |
function X = normrow(M)
tmp = M.^2;
tmp = sum(tmp,2);
[n c] = size(M);
X = zeros(n,c);
for i=1:n
X(i,:) = M(i,:)./sqrt(tmp(i));
end |
github | rammanouil/LaplacianRegularizationHyper-master | grid_image.m | .m | LaplacianRegularizationHyper-master/Supplementary_Functions/grid_image.m | 1,640 | utf_8 | 594d7806bdcfbbfaa46f184119baac99 |
function image_a = grid_image
R = 5;
N = 75;
sampla_a = zeros(R,R^2);
sampla_a(:,1:R) = [1,0,0,0,0;
0,1,0,0,0;
0,0,1,0,0;
0,0,0,0,1;
0,0,0,1,0];
sampla_a(:,R+1:2*R) = 1/2*[1,0,0,0,1;
1... |
github | rammanouil/LaplacianRegularizationHyper-master | AMY.m | .m | LaplacianRegularizationHyper-master/Supplementary_Functions/AMY.m | 355 | utf_8 | a8a5dfa81d0cadcd3e227e228d284bf5 |
function IDX = AMY(A,k)
Deg = diag(sum(A,1));
Ddemi = Deg^(-0.5);
L = Ddemi*A*Ddemi; % step 2 Normalized affinity
[X,D] = eigs(A,k); % step 3
Y = normrow(X); % step 4
IDX = kmeans(Y,k);
% IDX_image = reshape(IDX,h,w);
%
% figure; imshow(mat2gray(IDX_image)); colormap cool; colorbar
%%%%%%%%%%%%%%%%%%%%%%%%%%... |
github | rammanouil/LaplacianRegularizationHyper-master | permute_grid_image.m | .m | LaplacianRegularizationHyper-master/Supplementary_Functions/permute_grid_image.m | 1,180 | utf_8 | d692b142464bdf13fb065d4e09c2f02f |
% clear ; n = 2; R = 2; s = 1;
% [image_a] = grid_image2(n,R,s);
% figure ; imshow(image_a(:,:,1))
function Permuting_matrix = permute_grid_image(s,n,R)
h = R*n + 2*s*R ;
N = h*h ;
w = h;
Permuting_matrix = zeros(N,N);
background = 1:N;
background_remove = zeros(1,n*n*R*R);
count = 1;
for j=1:R % j before i to ... |
github | rammanouil/LaplacianRegularizationHyper-master | GLUP4_Lap.m | .m | LaplacianRegularizationHyper-master/Supplementary_Functions/GLUP4_Lap.m | 2,021 | utf_8 | 181c7a8035fc77794b321cc87119c564 |
function [X, Z, Y, RMSE, t, Niter ] = GLUP4_Lap(Sw,S,Adj,rho,mu,mu_L,tol,Nitermax,true_x,X0)
% x_sub, z_sub, y_sub, RMSE_sub, t_sub, Niter
% ADMM algorithl for group LASSO with positivity constraint and sum-to-one constraint
% variable X
% minimize( square_pos(norm(S-SwX,'fro')) + lambda * sum(norms(X,2,2)) ... |
github | sweeneychris/hpmvs-master | NLOPT_GN_ORIG_DIRECT.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_ORIG_DIRECT.m | 164 | utf_8 | 43ae70342fc7484716698f445981512b | % NLOPT_GN_ORIG_DIRECT: Original DIRECT version (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_ORIG_DIRECT
val = 6;
|
github | sweeneychris/hpmvs-master | NLOPT_LN_BOBYQA.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_BOBYQA.m | 189 | utf_8 | 15ba6db5057c8907343184908e0ecf06 | % NLOPT_LN_BOBYQA: BOBYQA bound-constrained optimization via quadratic models (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_BOBYQA
val = 34;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_DIRECT.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_DIRECT.m | 137 | utf_8 | 915b9f3f3a223d681a10bfaa80318309 | % NLOPT_GN_DIRECT: DIRECT (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_DIRECT
val = 0;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_MMA.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_MMA.m | 155 | utf_8 | 7e4519526e6353452086a1cf929b12ad | % NLOPT_LD_MMA: Method of Moving Asymptotes (MMA) (local, derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_MMA
val = 24;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_DIRECT_L.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_DIRECT_L.m | 143 | utf_8 | ae13ecf48a1ee6d222444643f59c2993 | % NLOPT_GN_DIRECT_L: DIRECT-L (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_DIRECT_L
val = 1;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_VAR1.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_VAR1.m | 168 | utf_8 | 45d4388965becdc240350c73a2779757 | % NLOPT_LD_VAR1: Limited-memory variable-metric, rank 1 (local, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_VAR1
val = 13;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_DIRECT_L_NOSCAL.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_DIRECT_L_NOSCAL.m | 166 | utf_8 | c20477ea33399f3311ea6e533dc347ae | % NLOPT_GN_DIRECT_L_NOSCAL: Unscaled DIRECT-L (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_DIRECT_L_NOSCAL
val = 4;
|
github | sweeneychris/hpmvs-master | NLOPT_LN_COBYLA.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_COBYLA.m | 189 | utf_8 | 2c95152f70105c8ca20929fba67d12a2 | % NLOPT_LN_COBYLA: COBYLA (Constrained Optimization BY Linear Approximations) (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_COBYLA
val = 25;
|
github | sweeneychris/hpmvs-master | NLOPT_LN_AUGLAG_EQ.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_AUGLAG_EQ.m | 189 | utf_8 | 5432778c9b81b5fdcfb98ca1bbbd6486 | % NLOPT_LN_AUGLAG_EQ: Augmented Lagrangian method for equality constraints (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_AUGLAG_EQ
val = 32;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_DIRECT_L_RAND.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_DIRECT_L_RAND.m | 164 | utf_8 | 2135dc3891b556738f41c2a35009b227 | % NLOPT_GN_DIRECT_L_RAND: Randomized DIRECT-L (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_DIRECT_L_RAND
val = 2;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_MLSL.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_MLSL.m | 169 | utf_8 | 93ab4e64e2760c4ca201fada42cb05c3 | % NLOPT_GN_MLSL: Multi-level single-linkage (MLSL), random (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_MLSL
val = 20;
|
github | sweeneychris/hpmvs-master | NLOPT_GD_MLSL_LDS.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GD_MLSL_LDS.m | 180 | utf_8 | 7f41fd0094df543c2e45280f86c0b87b | % NLOPT_GD_MLSL_LDS: Multi-level single-linkage (MLSL), quasi-random (global, derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GD_MLSL_LDS
val = 23;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_AUGLAG_EQ.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_AUGLAG_EQ.m | 186 | utf_8 | 41b81c30c553388e2ff1b6b1fb681618 | % NLOPT_LD_AUGLAG_EQ: Augmented Lagrangian method for equality constraints (local, derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_AUGLAG_EQ
val = 33;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_CCSAQ.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_CCSAQ.m | 214 | utf_8 | 33892896fe470090edb583b50b9e7d93 | % NLOPT_LD_CCSAQ: CCSA (Conservative Convex Separable Approximations) with simple quadratic approximations (local, derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_CCSAQ
val = 41;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_AUGLAG.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_AUGLAG.m | 155 | utf_8 | 2d7d515e911b5d0277490940a47f333e | % NLOPT_LD_AUGLAG: Augmented Lagrangian method (local, derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_AUGLAG
val = 31;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_DIRECT_L_RAND_NOSCAL.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_DIRECT_L_RAND_NOSCAL.m | 187 | utf_8 | 3287f776b0f2ac5e3495c2a4c95ba4e7 | % NLOPT_GN_DIRECT_L_RAND_NOSCAL: Unscaled Randomized DIRECT-L (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_DIRECT_L_RAND_NOSCAL
val = 5;
|
github | sweeneychris/hpmvs-master | NLOPT_LN_SBPLX.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_SBPLX.m | 196 | utf_8 | c99ee02eb277898e9c509dd359740680 | % NLOPT_LN_SBPLX: Sbplx variant of Nelder-Mead (re-implementation of Rowan's Subplex) (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_SBPLX
val = 29;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_ISRES.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_ISRES.m | 173 | utf_8 | 2c12964785aed0828a5ac17fc416f5be | % NLOPT_GN_ISRES: ISRES evolutionary constrained optimization (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_ISRES
val = 35;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_VAR2.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_VAR2.m | 168 | utf_8 | 5ba0bd034c240547765a0fd4ce90c825 | % NLOPT_LD_VAR2: Limited-memory variable-metric, rank 2 (local, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_VAR2
val = 14;
|
github | sweeneychris/hpmvs-master | NLOPT_AUGLAG_EQ.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_AUGLAG_EQ.m | 182 | utf_8 | 2f8b59b483a4f2621264c7de9df58365 | % NLOPT_AUGLAG_EQ: Augmented Lagrangian method for equality constraints (needs sub-algorithm)
%
% See nlopt_minimize for more information.
function val = NLOPT_AUGLAG_EQ
val = 37;
|
github | sweeneychris/hpmvs-master | NLOPT_LN_NELDERMEAD.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_NELDERMEAD.m | 168 | utf_8 | 219928fdd3fc8317d321f9f0535d550f | % NLOPT_LN_NELDERMEAD: Nelder-Mead simplex algorithm (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_NELDERMEAD
val = 28;
|
github | sweeneychris/hpmvs-master | NLOPT_LN_NEWUOA.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_NEWUOA.m | 185 | utf_8 | b318db6792885a5d23dcfd5b28fdc507 | % NLOPT_LN_NEWUOA: NEWUOA unconstrained optimization via quadratic models (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_NEWUOA
val = 26;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_CRS2_LM.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_CRS2_LM.m | 185 | utf_8 | 9a171159b83c77e07256a24704139d8a | % NLOPT_GN_CRS2_LM: Controlled random search (CRS2) with local mutation (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_CRS2_LM
val = 19;
|
github | sweeneychris/hpmvs-master | NLOPT_LN_PRAXIS.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_PRAXIS.m | 153 | utf_8 | c7d354e0602183d0d3a7ff71641ab7b4 | % NLOPT_LN_PRAXIS: Principal-axis, praxis (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_PRAXIS
val = 12;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_SLSQP.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_SLSQP.m | 164 | utf_8 | e767cc9cde902065e67a31664a571819 | % NLOPT_LD_SLSQP: Sequential Quadratic Programming (SQP) (local, derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_SLSQP
val = 40;
|
github | sweeneychris/hpmvs-master | NLOPT_G_MLSL_LDS.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_G_MLSL_LDS.m | 187 | utf_8 | dfafcdb44b43c59aa5e4d5b73542dc50 | % NLOPT_G_MLSL_LDS: Multi-level single-linkage (MLSL), quasi-random (global, needs sub-algorithm)
%
% See nlopt_minimize for more information.
function val = NLOPT_G_MLSL_LDS
val = 39;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_TNEWTON.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_TNEWTON.m | 152 | utf_8 | 5e00532d1e34e85f395f6ace048d7d64 | % NLOPT_LD_TNEWTON: Truncated Newton (local, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_TNEWTON
val = 15;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_LBFGS_NOCEDAL.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_LBFGS_NOCEDAL.m | 184 | utf_8 | 7b1380ab03a2272b6e3f1c0f49e4babf | % NLOPT_LD_LBFGS_NOCEDAL: original NON-FREE L-BFGS code by Nocedal et al. (NOT COMPILED)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_LBFGS_NOCEDAL
val = 10;
|
github | sweeneychris/hpmvs-master | NLOPT_GD_STOGO.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GD_STOGO.m | 137 | utf_8 | 1b374b07cc8dd1fd43998c8f60f49267 | % NLOPT_GD_STOGO: StoGO (global, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_GD_STOGO
val = 8;
|
github | sweeneychris/hpmvs-master | NLOPT_AUGLAG.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_AUGLAG.m | 151 | utf_8 | a4a6ef23ad60f4ceab26caae4276c02d | % NLOPT_AUGLAG: Augmented Lagrangian method (needs sub-algorithm)
%
% See nlopt_minimize for more information.
function val = NLOPT_AUGLAG
val = 36;
|
github | sweeneychris/hpmvs-master | NLOPT_GD_MLSL.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GD_MLSL.m | 166 | utf_8 | 3735615f01a5de64ba710bfa7b7eba3a | % NLOPT_GD_MLSL: Multi-level single-linkage (MLSL), random (global, derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GD_MLSL
val = 21;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_DIRECT_NOSCAL.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_DIRECT_NOSCAL.m | 160 | utf_8 | 9f11af031bd7ca9c9348de64f7169482 | % NLOPT_GN_DIRECT_NOSCAL: Unscaled DIRECT (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_DIRECT_NOSCAL
val = 3;
|
github | sweeneychris/hpmvs-master | NLOPT_LN_AUGLAG.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_AUGLAG.m | 158 | utf_8 | ec49cb21c2b454870a401a1c5afd1058 | % NLOPT_LN_AUGLAG: Augmented Lagrangian method (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_AUGLAG
val = 30;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_ESCH.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_ESCH.m | 130 | utf_8 | 6cad4da90ce4145ad2b1dafcf286286f | % NLOPT_GN_ESCH: ESCH evolutionary strategy
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_ESCH
val = 42;
|
github | sweeneychris/hpmvs-master | NLOPT_G_MLSL.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_G_MLSL.m | 173 | utf_8 | fd60012f2c05bdeb027ee6dee44175fb | % NLOPT_G_MLSL: Multi-level single-linkage (MLSL), random (global, needs sub-algorithm)
%
% See nlopt_minimize for more information.
function val = NLOPT_G_MLSL
val = 38;
|
github | sweeneychris/hpmvs-master | nlopt_minimize_constrained.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/nlopt_minimize_constrained.m | 5,174 | utf_8 | 2093a6be53db585559168905f1fc1e4a | % Usage: [xopt, fmin, retcode] = nlopt_minimize_constrained
% (algorithm, f, f_data,
% fc, fc_data, lb, ub,
% xinit, stop)
%
% Minimizes a nonlinear multivariable function f(x, f_data{:}), subjec... |
github | sweeneychris/hpmvs-master | NLOPT_LN_NEWUOA_BOUND.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LN_NEWUOA_BOUND.m | 207 | utf_8 | 67ca43d03f5347c97069a86e3e73a7e4 | % NLOPT_LN_NEWUOA_BOUND: Bound-constrained optimization via NEWUOA-based quadratic models (local, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_LN_NEWUOA_BOUND
val = 27;
|
github | sweeneychris/hpmvs-master | nlopt_minimize.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/nlopt_minimize.m | 3,978 | utf_8 | f71b68688b460e0440ff89bdf086d2a7 | % Usage: [xopt, fmin, retcode] = nlopt_minimize(algorithm, f, f_data, lb, ub,
% xinit, stop)
%
% Minimizes a nonlinear multivariable function f(x, f_data{:}), where
% x is a row vector, returning the optimal x found (xopt) along with
% the minimum function value (fmin = f(x... |
github | sweeneychris/hpmvs-master | NLOPT_GN_ORIG_DIRECT_L.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_ORIG_DIRECT_L.m | 170 | utf_8 | d61c095f05bf7fd4fbbf2ddbe22c58a4 | % NLOPT_GN_ORIG_DIRECT_L: Original DIRECT-L version (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_ORIG_DIRECT_L
val = 7;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_TNEWTON_RESTART.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_TNEWTON_RESTART.m | 184 | utf_8 | a482ddde1f6d6b386a3810fc142829a2 | % NLOPT_LD_TNEWTON_RESTART: Truncated Newton with restarting (local, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_TNEWTON_RESTART
val = 16;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_TNEWTON_PRECOND_RESTART.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_TNEWTON_PRECOND_RESTART.m | 215 | utf_8 | 1082f147b249cc1f7e564aa3b2462048 | % NLOPT_LD_TNEWTON_PRECOND_RESTART: Preconditioned truncated Newton with restarting (local, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_TNEWTON_PRECOND_RESTART
val = 18;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_TNEWTON_PRECOND.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_TNEWTON_PRECOND.m | 183 | utf_8 | 167e47e5e372152ffba7552308e1193f | % NLOPT_LD_TNEWTON_PRECOND: Preconditioned truncated Newton (local, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_TNEWTON_PRECOND
val = 17;
|
github | sweeneychris/hpmvs-master | NLOPT_GD_STOGO_RAND.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GD_STOGO_RAND.m | 170 | utf_8 | fea04c6327afd49e02ff536330527f60 | % NLOPT_GD_STOGO_RAND: StoGO with randomized search (global, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_GD_STOGO_RAND
val = 9;
|
github | sweeneychris/hpmvs-master | NLOPT_LD_LBFGS.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_LD_LBFGS.m | 160 | utf_8 | 02936ac48fc420cd73b5a6848808dd68 | % NLOPT_LD_LBFGS: Limited-memory BFGS (L-BFGS) (local, derivative-based)
%
% See nlopt_minimize for more information.
function val = NLOPT_LD_LBFGS
val = 11;
|
github | sweeneychris/hpmvs-master | NLOPT_GN_MLSL_LDS.m | .m | hpmvs-master/thirdLibs/nlopt-2.4.2/octave/NLOPT_GN_MLSL_LDS.m | 183 | utf_8 | 0fb34e2ebed6204b06925782f5fc2417 | % NLOPT_GN_MLSL_LDS: Multi-level single-linkage (MLSL), quasi-random (global, no-derivative)
%
% See nlopt_minimize for more information.
function val = NLOPT_GN_MLSL_LDS
val = 22;
|
github | jmfoster/arl-master | simSymmetric.m | .m | arl-master/simSymmetric.m | 1,305 | utf_8 | 8b73c5b63f1bb7559e4e91cd019aa735 | %returns max of featural simScores between g2 and all symmetries
%of g1 (rotational and reflective)
% midway between featural and full relational similarity for
% tic-tac-toe domain
function [simScore bestG1 g2] = simSymmetric(g1, g2)
%param
theta = 1;
%[g1 g2] = ttt.equalizePlayerPerspectives(g1, g2); don... |
github | aamarasingham/bjitter-master | Figure2.m | .m | bjitter-master/Figure2.m | 4,513 | utf_8 | 6007452143d1e11e0a5eb839f620008a | % Matlab code to make Figure 2 for "Spike-centered jitter can mistake temporal structure" (Platkiewicz, Stark, Amarasingham)
% Generates Poisson spike trains and compares "p-value" distributions
% for interval vs. basic (spike-centered) jitter, using a synchrony
% statistic. Refer to manuscript for details.
% (C) Asoha... |
github | aamarasingham/bjitter-master | Appendix_Section_5_3.m | .m | bjitter-master/Appendix_Section_5_3.m | 4,710 | utf_8 | 60016a8c86d59772e3c41689b1f862a7 | % Matlab code to make Figure 2 for “Spike-centered jitter can mistake temporal structure” (Platkiewicz, Stark, Amarasingham)
% Generates Poisson spike trains and compares "p-value" distributions
% for interval vs. basic (spike-centered) jitter, using a synchrony
% statistic. Synchronies are injected to demonstrate sens... |
github | lmthang/nmt.hybrid-master | trainLSTM.m | .m | nmt.hybrid-master/code/trainLSTM.m | 32,178 | utf_8 | ab603f1b1d2213c0333f278f525c7897 | function trainLSTM(trainPrefix,validPrefix,testPrefix,srcLang,tgtLang,srcVocabFile,tgtVocabFile,outDir,varargin)
% Train Long-Short Term Memory (LSTM) models.
% Arguments:
% trainPrefix, validPrefix, testPrefix: expect files trainPrefix.srcLang,
% trainPrefix.tgtLang. Similarly for validPrefix and testPrefix.
%... |
github | lmthang/nmt.hybrid-master | lstmDecoder.m | .m | nmt.hybrid-master/code/lstmDecoder.m | 24,461 | utf_8 | 2768ea96dfcd39475bf8dac5a2370637 | function [candidates, candScores, alignInfo, otherInfo] = lstmDecoder(models, data, params)
% Decode from an LSTM model.
% stackSize: the maximum number of translations we want to get.
% Output:
% - candidates: list of candidates
% - candScores: score of the corresponding candidates (stackSize * batchSize)
%
% Th... |
github | lmthang/nmt.hybrid-master | lstmCostGrad.m | .m | nmt.hybrid-master/code/lstmCostGrad.m | 6,668 | utf_8 | 155c808d582984f3c58829268c8bfdc7 | function [costs, grad, charInfo] = lstmCostGrad(model, trainData, params, isTest)
%%%
%
% Compute cost/grad for LSTM.
% When params.predictPos>0, returns costs.pos and costs.word
% If isTest==1, this method only computes cost (for testing purposes).
%
% Thang Luong @ 2014, 2015, <lmthang@stanford.edu>
%
%%%
%%%%%%%... |
github | lmthang/nmt.hybrid-master | computeRerankScores.m | .m | nmt.hybrid-master/code/computeRerankScores.m | 8,102 | utf_8 | 16b7d973b657ea893c3da5b36325876b | function [] = computeRerankScores(modelFiles, outputFile,varargin)
% Compute decoding scores
% Arguments:
% modelFiles: single or multiple models to decode. Multiple models are
% separated by commas.
% outputFile: output scores file.
% varargin: other optional arguments.
%
% Thang Luong @ 2016, <lmthang@stanf... |
github | lmthang/nmt.hybrid-master | evalCost.m | .m | nmt.hybrid-master/code/misc/evalCost.m | 404 | utf_8 | 804a9e090d5ec84559573d828d6c66a5 | %% Eval
function [evalCosts, totalNumChars] = evalCost(model, data, params)
numBatches = data.numBatches;
evalCosts = initCosts(params);
totalNumChars = 0;
for batchId = 1 : numBatches
% eval
[costs, ~, charInfo] = lstmCostGrad(model, data.batches{batchId}, params, 1);
totalNumChars = totalNumCh... |
github | lmthang/nmt.hybrid-master | getAlignWeights.m | .m | nmt.hybrid-master/code/misc/getAlignWeights.m | 2,990 | utf_8 | 47a161d0166bf0cb5233cb41099c3e14 | function [alignWeights, alignIndices] = getAlignWeights(attnInfos, srcLens, models, params)
assert(params.attnFunc>0);
batchSize = length(srcLens);
numModels = length(models);
% init
alignWeights = cell(batchSize, 1);
for sentId=1:batchSize % go through each sent
alignWeights{sentId} = zeroMatrix([srcL... |
github | lmthang/nmt.hybrid-master | transferModel.m | .m | nmt.hybrid-master/code/misc/transferModel.m | 5,648 | utf_8 | 985b02401d1a17dca9787f8098ff5cb0 | function transferModel(modelFile, srcVocabFile_new, tgtVocabFile_new, srcCharPrefix_new, tgtCharPrefix_new, outModelFile, varargin)
addpath(genpath(sprintf('%s/../..', pwd)));
%% Argument Parser
p = inputParser;
% required
addRequired(p,'modelFile',@ischar);
addRequired(p,'srcVocabFile_new',@ischar);
a... |
github | lmthang/nmt.hybrid-master | buildSrcVecs.m | .m | nmt.hybrid-master/code/misc/buildSrcVecs.m | 3,235 | utf_8 | 4531f36b3b402df4e83987e250a403e3 | %%%
%
% Gather src hidden vectors for attention-based models.
% For each sentence ii, we extract a set of vectors to pay attention to
% srcVecsAll(:, ii, srcPositions(ii)-posWin:srcPositions(ii)+posWin)
% and put it into srcVecs(:, ii, :). Boundary cases are handled as well.
%
% Thang Luong @ 2015, <lmthang@stanfor... |
github | lmthang/nmt.hybrid-master | softmax.m | .m | nmt.hybrid-master/code/basic/softmax.m | 903 | utf_8 | 1186c5653ae28fd6f4ed92946e192aea | %%
%
% Efficient (hopefully) softmax implementation.
% Return normalized probs as well as scores (numerators in log domain) & norms.
% Note that scores & norms are subtracted/scaled by a constant factor.
% If mask exists, mask out probs.
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
% Hieu Pham @ 2015, <hyhieu@cs.stan... |
github | lmthang/nmt.hybrid-master | printDecodeResults.m | .m | nmt.hybrid-master/code/print/printDecodeResults.m | 4,491 | utf_8 | 4b7521d5348fbc6913b1fac325e4bf57 | function printDecodeResults(decodeData, candidates, candScores, alignInfo, otherInfo, params, isOutput)
batchSize = size(candScores, 2);
startId = decodeData.startId;
% output translations
[maxScores, bestIndices] = max(candScores, [], 1); % stackSize * batchSize
for ii = 1:batchSize
bestId = bestIndic... |
github | lmthang/nmt.hybrid-master | wInfo.m | .m | nmt.hybrid-master/code/print/wInfo.m | 1,206 | utf_8 | eef19a715530908922a8bd204b035e4a | function [output] = wInfo(allW, opt)
if ~exist('opt', 'var')
opt = -1;
end
output = '';
if isstruct(allW) % struct
fields = fieldnames(allW);
for ii=1:length(fields)
field = fields{ii};
if iscell(allW.(field))
for jj=1:length(allW.(field))
output = [out... |
github | lmthang/nmt.hybrid-master | lstmUnitForward.m | .m | nmt.hybrid-master/code/layers/lstmUnitForward.m | 3,877 | utf_8 | ffdce0ec3241de33ae957901b486fbfc | function [lstmState] = lstmUnitForward(W, x_t, h_t_1, c_t_1, params, rnnFlags)
% LSTM unit
% Input:
% W: parameter
% x_t: current input
% h_t_1, c_t_1: previous hidden state, cell state
% isTest: 1 -- don't store intermediate results
%
% Output:
% lstmState struct
% Thang Luong @ 2014, 2015, <lmthang@stanford... |
github | lmthang/nmt.hybrid-master | scaleLayerBackprop.m | .m | nmt.hybrid-master/code/layers/scaleLayerBackprop.m | 957 | utf_8 | a594f21d7f02637c33a4a7922a8131ca | %%%
%
% Backprop from the predicted relative positions (scales) to lstm hidden states h_t.
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%
%%%
function [grad_ht, grad_W_pos, grad_v_pos] = scaleLayerBackprop(W_pos, v_pos, grad_scales, h_t, scales, forwardData, params)
% scales -> h_pos
[grad_h_pos, grad_v_pos] = h... |
github | lmthang/nmt.hybrid-master | attnLayerBackprop.m | .m | nmt.hybrid-master/code/layers/attnLayerBackprop.m | 5,029 | utf_8 | 38f4664369f0a0f5ac67039e519c84e2 | %%%
%
% Attentional Layer Backprop from softmax hidden state to lstm hidden state.
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%
%%%
function [grad_ht, attnGrad, grad_srcHidVecs] = attnLayerBackprop(model, grad_softmax_h, trainData, attnInfo, params, curMask, ...
rareAttnInputGrad_char, rareIndices)
% softmax_h... |
github | lmthang/nmt.hybrid-master | softmaxLayerBackprop.m | .m | nmt.hybrid-master/code/layers/softmaxLayerBackprop.m | 322 | utf_8 | 5f8ca3dd58fa979bc73a06bc1e5c56a6 | %%
%
% Perform softmax backprop.
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%
%%
function [grad_W, inGrad] = softmaxLayerBackprop(W, inVec, probs, scoreIndices)
probs(scoreIndices) = probs(scoreIndices) - 1; % minus one at predicted words
% softmax_h
inGrad = W'* probs;
% W_soft
grad_W = probs*inVec';
e... |
github | lmthang/nmt.hybrid-master | linearLayerForward.m | .m | nmt.hybrid-master/code/layers/linearLayerForward.m | 164 | utf_8 | e599e80bc23c0727b4bc49954d7dee5f | %%%
%
% Linear transformation W*inVec
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%
%%%
function [outVec] = linearLayerForward(W, inVec)
outVec = W*inVec;
end |
github | lmthang/nmt.hybrid-master | normLayerForward.m | .m | nmt.hybrid-master/code/layers/normLayerForward.m | 775 | utf_8 | 422af1ccbd333aa7d1b737188d134399 | %%
%
% Return normalized probs as well as scores (numerators in log domain) & norms.
% Note that scores & norms are subtracted/scaled by a constant factor.
%
% Here, we only work on a subset linearIds of the raw scores.
%
% Thang Luong @ 2015, <lmthang@stanford.edu
%
%%
function [probs, scores, norms] = normLayerForwa... |
github | lmthang/nmt.hybrid-master | distLayerForward.m | .m | nmt.hybrid-master/code/layers/distLayerForward.m | 960 | utf_8 | 4e4e826c1acc282a7f751c189b8b5898 | % Use gaussian probabilities to weight src hidden states
function [distWeights, scaleX] = distLayerForward(mu, h2sInfo, params)
if params.isReverse % get back correct source positions
srcPositions = params.srcMaxLen - h2sInfo.indicesAll;
else
error('attn4 has not supported inverse yet\n');
end
scaleX =... |
github | lmthang/nmt.hybrid-master | attnLayerForward.m | .m | nmt.hybrid-master/code/layers/attnLayerForward.m | 4,298 | utf_8 | cb0105ddbfef079d4a9c4afdde11e154 | function [attnInfo] = attnLayerForward(h_t, params, model, attnData, maskInfo)
%
% Attentional Layer: from lstm hidden state to softmax hidden state.
% Input:
% attnData: require attnData.srcHidVecsOrig and attnData.srcLens
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%
attnInfo = [];
if params.attnGlobal % gl... |
github | lmthang/nmt.hybrid-master | lstmUnitBackprop.m | .m | nmt.hybrid-master/code/layers/lstmUnitBackprop.m | 4,194 | utf_8 | 6fa2611c02dc8f05a1b48563bbb57b4a | function [dc, dh, d_input, d_W_rnn] = lstmUnitBackprop(W, lstm, c_t_1, dc, dh, maskedIds, params, isFeedInput)
% LSTM unit back prop
% Input:
% W: recurrent parameters
% c_t_1: previous cell state
%
% Output:
% gradients with respect to c, h, input, and the recurrent connenctions
% Thang Luong @ 2014, 2015, <lmth... |
github | lmthang/nmt.hybrid-master | linearLayerBackprop.m | .m | nmt.hybrid-master/code/layers/linearLayerBackprop.m | 253 | utf_8 | 61ebf25af3a1c1194cd4b7cf420ce724 | %%
% Forward outVec = W*inVec
% Compute inGrad, grad_W
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%%
function [inGrad, grad_W] = linearLayerBackprop(W, outGrad, inVec)
% grad_W
grad_W = outGrad*inVec';
% inGrad
inGrad = W'*outGrad;
end |
github | lmthang/nmt.hybrid-master | softmaxLayerForward.m | .m | nmt.hybrid-master/code/layers/softmaxLayerForward.m | 540 | utf_8 | 1b661dfde325dc1e378c945221b8bca6 | %%
% Perform softmax prediction.
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%
%%
function [cost, probs, scores, scoreIndices] = softmaxLayerForward(W, inVec, predLabels, curMask)
mask = curMask.mask;
unmaskedIds = curMask.unmaskedIds;
% softmax_h -> predictions
[probs, scores, norms] = softmax(W*inVec, m... |
github | lmthang/nmt.hybrid-master | hiddenLayerBackprop.m | .m | nmt.hybrid-master/code/layers/hiddenLayerBackprop.m | 549 | utf_8 | 67c0e83ed9bef9bdce8bf6b82eed6159 | %%
% Forward outVec = f(W*inVec)
% Compute inGrad, grad_W
% IMPORTANT: this method only works when nonlinear_f_prime is either for
% sigmoid or tanh in which we can reuse the forward computation (outVec)
% to compute the gradient faster.
% Thang Luong @ 2015, <lmthang@stanford.edu>
%%
function [inGrad, grad_W] = ... |
github | lmthang/nmt.hybrid-master | hiddenLayerForward.m | .m | nmt.hybrid-master/code/layers/hiddenLayerForward.m | 196 | utf_8 | 23bfa4a31fa4637f293f7dc7ab1e3e6d | %%%
%
% Nonlinear transformation f(W*inVec)
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%
%%%
function [outVec] = hiddenLayerForward(W, inVec, nonlinear_f)
outVec = nonlinear_f(W*inVec);
end |
github | lmthang/nmt.hybrid-master | contextLayerForward.m | .m | nmt.hybrid-master/code/layers/contextLayerForward.m | 1,272 | utf_8 | 3a97d2341d736c05b67ee7bda3c0efa8 | %%%
%
% For attention-based models, given:
% alignWeights: numPositions * batchSize.
% srcHidVecs: lstmSize * batchSize * numPositions.
% compute the context vectors (weighted sum):
% contextVecs: lstmSize * batchSize.
%
% Thang Luong @ 2015, <lmthang@stanford.edu>
%
%%%
function [contextVecs] = contextLayerForw... |
github | lmthang/nmt.hybrid-master | distLayerBackprop.m | .m | nmt.hybrid-master/code/layers/distLayerBackprop.m | 1,137 | utf_8 | d7f67eb6280a27034fe16fb27f636b24 | function [grad_mu] = distLayerBackprop(grad_distWeights, h2sInfo, params)
% since linearIdSub is for matrix of size [curBatchSize, numAttnPositions],
% we need to transpose grad_alignWeights to be of that size.
grad_distWeights = grad_distWeights';
distWeights = h2sInfo.distWeights';
if params.assert
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.