def initializePruning(): global blockList #ip.getBlockList('vgg16') global featureList global convIdx global module global prune_count blockList = ip.createBlockList(newModel) #ip.getBlockList('vgg16') featureList = ip.createFeatureList(newModel) convIdx = ip.findConvIndex(newModel) module = ip.getPruneModule(newModel) prune_count = ip.getPruneCount(module=module, blocks=blockList, maxpr=.1) global newList global layer_number global st global en global candidateConvLayer newList = [] layer_number = 0 st = 0 en = 0 candidateConvLayer = [] print(f"Block List = {blockList}\n" f"Feature List = {featureList}\n" f"Conv Index = {convIdx}\n" f"Prune Count = {prune_count}\n" f"Start Index = {st}\n" f"End Index = {en}\n" f"Initial Layer Number = {layer_number}\n" f"Empy candidate layer list = {candidateConvLayer}")
def initializePruning(): global blockList #ip.getBlockList('vgg16') global featureList global convIdx global module global prune_count with open(outLogFile, "a") as f: blockList = ip.createBlockList(newModel) #ip.getBlockList('vgg16') featureList = ip.createFeatureList(newModel) convIdx = ip.findConvIndex(newModel) module = ip.getPruneModule(newModel) prune_count = ip.getPruneCount(module=module, blocks=blockList, maxpr=.1) global newList global layer_number global st global en global candidateConvLayer newList = [] layer_number = 0 st = 0 en = 0 candidateConvLayer = [] f.write(f"\nBlock List = {blockList}" f"\nFeature List = {featureList}" f"\nConv Index = {convIdx}" f"\nPrune Count = {prune_count}" f"\nStart Index = {st}" f"\nEnd Index = {en}" f"\nInitial Layer Number = {layer_number}" f"\nEmpy candidate layer list = {candidateConvLayer}") f.close()
# Set all the Hyper-Parameter for training epochs=1, max_lr=0.01, weight_decay=0, L1=0, grad_clip=.1, logFile=logFile) #Save the trained model SavePath = '/home/pragnesh/Model/vgg16-v2' torch.save(newModel, SavePath) # ## Pruning # #### Pruning Initialization # In[4]: blockList = ip.createBlockList(newModel) #ip.getBlockList('vgg16') featureList = ip.createFeatureList(newModel) convIdx = ip.findConvIndex(newModel) module = ip.getPruneModule(newModel) prune_count = ip.getPruneCount(module=module,blocks=blockList,maxpr=.1) print(f"Block List = {blockList}\n" f"Feature List = {featureList}\n" f"Conv Index = {convIdx}\n" f"Prune Count = {prune_count}" ) # for i in range(len(module)): # print(f"{i+1} :{module[i]}") # #### Implementing custom pruning process