parameters: (directory,ax)
return_statement: return True
docstring: Read activations from file, and plot them.
docstring_summary: Read activations from file, and plot them.
docstring_tokens: Read activations from file and plot them .
function: def plotBasisFunctionsFromDirectory(directory,ax):
      """Read activations from file, and plot them."""
    
      # Relevant files
      #   n_samples_per_dim.txt
      #   inputs_grid.txt
      #   activations_grid.txt
      #   activations_weighted_grid.txt
      #   predictions_grid.txt
  
      inputs   = numpy.loadtxt(directory+'/inputs_grid.txt')    
      n_dims = len(numpy.atleast_1d(inputs[0]))
      if (n_dims>2):
          sys.exit('Cannot plot input data with a dimensionality of '+str(n_dims)+'.')
      
      cosine_basis_functions = False
  
      try:
          filename = directory+'/n_samples_per_dim.txt'
          n_samples_per_dim = numpy.loadtxt(filename,dtype=int)                             
      except IOError:
          # Assume data is 1D
          n_samples_per_dim = len(inputs)
          
      #try:
      #    predictions  = numpy.loadtxt(directory+'/predictions_grid.txt')
      #    plotDataPredictionsGrid(inputs,predictions,ax,n_samples_per_dim)
      #except IOError:
      #    predictions = [];
          
      lines_bfs = None
      if (n_dims<2):
          try:
              activations  = numpy.loadtxt(directory+'/activations_grid.txt')
              lines_bfs = plotBasisFunctions(inputs,activations,ax,n_samples_per_dim,cosine_basis_functions) 
          except IOError:
              activations = None
  
      lines_bfs_weighted = None;
      try:
          activations_weighted  = numpy.loadtxt(directory+'/activations_weighted_grid.txt')
          lines_bfs_weighted = plotBasisFunctions(inputs,activations_weighted,ax,n_samples_per_dim,cosine_basis_functions) 
      except IOError:
          activations_weighted_grid = None;
  
      if (n_dims==1):
          if lines_bfs_weighted is not None and lines_bfs is not None:
              # Both are plotted, give different colors
              plt.setp(lines_bfs_weighted,color='green')
              plt.setp(lines_bfs,color='#aaffaa')
          else:
              if lines_bfs_weighted is not None:
                  plt.setp(lines_bfs,color='green')
              if lines_bfs != None:
                  plt.setp(lines_bfs,color='green')
  
      if (n_dims==1):
        ax.set_xlabel('input');
        ax.set_ylabel('activation');
      else:
        ax.set_xlabel('input_1');
        ax.set_ylabel('input_2');
        ax.set_zlabel('activation');
        
      return True
function_tokens: def plotBasisFunctionsFromDirectory ( directory , ax ) : # Relevant files #   n_samples_per_dim.txt #   inputs_grid.txt #   activations_grid.txt #   activations_weighted_grid.txt #   predictions_grid.txt inputs = numpy . loadtxt ( directory + '/inputs_grid.txt' ) n_dims = len ( numpy . atleast_1d ( inputs [ 0 ] ) ) if ( n_dims > 2 ) : sys . exit ( 'Cannot plot input data with a dimensionality of ' + str ( n_dims ) + '.' ) cosine_basis_functions = False try : filename = directory + '/n_samples_per_dim.txt' n_samples_per_dim = numpy . loadtxt ( filename , dtype = int ) except IOError : # Assume data is 1D n_samples_per_dim = len ( inputs ) #try: #    predictions  = numpy.loadtxt(directory+'/predictions_grid.txt') #    plotDataPredictionsGrid(inputs,predictions,ax,n_samples_per_dim) #except IOError: #    predictions = []; lines_bfs = None if ( n_dims < 2 ) : try : activations = numpy . loadtxt ( directory + '/activations_grid.txt' ) lines_bfs = plotBasisFunctions ( inputs , activations , ax , n_samples_per_dim , cosine_basis_functions ) except IOError : activations = None lines_bfs_weighted = None try : activations_weighted = numpy . loadtxt ( directory + '/activations_weighted_grid.txt' ) lines_bfs_weighted = plotBasisFunctions ( inputs , activations_weighted , ax , n_samples_per_dim , cosine_basis_functions ) except IOError : activations_weighted_grid = None if ( n_dims == 1 ) : if lines_bfs_weighted is not None and lines_bfs is not None : # Both are plotted, give different colors plt . setp ( lines_bfs_weighted , color = 'green' ) plt . setp ( lines_bfs , color = '#aaffaa' ) else : if lines_bfs_weighted is not None : plt . setp ( lines_bfs , color = 'green' ) if lines_bfs != None : plt . setp ( lines_bfs , color = 'green' ) if ( n_dims == 1 ) : ax . set_xlabel ( 'input' ) ax . set_ylabel ( 'activation' ) else : ax . set_xlabel ( 'input_1' ) ax . set_ylabel ( 'input_2' ) ax . set_zlabel ( 'activation' ) return True