XinLi-zn / TADT

Implementation of the TADT tracker of paper 'Target-Aware Deep Tracking'
67 stars 16 forks source link

state is empty when first run the TADT #7

Closed sunzhen6251 closed 5 years ago

sunzhen6251 commented 5 years ago

The error like this :

Struct contents reference from a non-struct array object.

Error in solver.adam (line 62)
state.m = opts.beta1 * state.m + (1 - opts.beta1) * grad ;

Error in cnn_train_dag_ridge>accumulateGradients (line 375)
          params.solver(net.params(p).value, state.solverState{p}, ...

Error in cnn_train_dag_ridge>processEpoch (line 282)
    state = accumulateGradients(net, state, params, batchSize, parserv) ;

Error in cnn_train_dag_ridge (line 114)
    [net, state, ders_iter(:,epoch)] = processEpoch(net, input, state, params, 'train') ;

I find that the params.solver is @solver.adam but the state.solverState{p} is blank in the below code. The code of initialize the state is enabled when the params.solver is empty.

      if isempty(params.solver)
        if isempty(state.solverState{p})
          state.solverState{p} = zeros(size(parDer), 'like', parDer);
        end

        state.solverState{p} = vl_taccum(...
          params.solverOpts.momentum,  state.solverState{p}, ...
          - (1 / batchSize), parDer) ;
        net.params(p).value = vl_taccum(...
          (1 - thisLR * thisDecay / (1 - params.solverOpts.momentum)),  ...
          net.params(p).value, ...
          thisLR, state.solverState{p}) ;
      else
        grad = (1 / batchSize) * parDer + thisDecay * net.params(p).value;
        % call solver function to update weights
        [net.params(p).value, state.solverState{p}] = ...
          params.solver(net.params(p).value, state.solverState{p}, ...
          grad, params.solverOpts, thisLR) ;
      end

so it cause a error when calling params.solver(). how should I fix it ?

Thanks !

sunzhen6251 commented 5 years ago

I have fixed this issue by modify the line 57 in adam.m

if (isequal(state, 0) || isempty(state))   % start off with state = 0 so as to get default state
  state = struct('m', 0, 'v', 0, 't', 0);
end