Home > other >  For years, help comment the meaning of every line of code
For years, help comment the meaning of every line of code

Time:09-20

The from keras. Models import Sequential
The from keras. The layers import Dense, Dropout, Flatten
The from keras. The layers import LocallyConnected1D, Conv1D
The from keras. Optimizers import SGD, Adam, Adagrad, RMSprop, Adadelta, Adamax
The from numpy import *
The import numpy as np
The import keras
The import matplotlib. Pyplot as PLT
% matplotlib inline
Na=111
Nb=1
Nc=520
Nd=850
# training set
T=0
Dataa=np. Zeros ((na, nc, 3))
For filename in [' A0F01. Dat ', 'A0F02. Dat', 'A0F03. Dat', 'A0F04. Dat', 'A0F05. Dat', 'A0F06. Dat', 'A0F07. Dat', 'A0F08. Dat', 'A0F09. Dat', 'A0F010. Dat,
'A0F011. Dat', 'A0F012. Dat', 'A0F013. Dat', 'A0F014. Dat', 'A0F015. Dat', 'A0F016. Dat', 'A0F017. Dat', 'A0F018. Dat', 'A0F019. Dat', 'A0F020. Dat'
'A0F021. Dat', 'A0F022. Dat', 'A0F023. Dat', 'A0F024. Dat', 'A0F025. Dat', 'A0F026. Dat', 'A0F027. Dat', 'A0F028. Dat', 'A0F029. Dat', 'A0F030. Dat'
'A0F031. Dat', 'A0F032. Dat', 'A0F033. Dat', 'A0F034. Dat', 'A0F035. Dat', 'A0F036. Dat', 'A0F037. Dat', 'A0F038. Dat', 'A0F039. Dat', 'A0F040. Dat'
'A0F041. Dat', 'A0F042. Dat', 'A0F043. Dat', 'A0F044. Dat', 'A0F045. Dat', 'A0F046. Dat', 'A0F047. Dat', 'A0F048. Dat', 'A0F049. Dat', 'A0F050. Dat'
'A0F051. Dat', 'A0F052. Dat', 'A0F053. Dat', 'A0F054. Dat', 'A0F055. Dat', 'A0F056. Dat', 'A0F057. Dat', 'A0F058. Dat', 'A0F059. Dat', 'A0F060. Dat'
'A0F061. Dat', 'A0F062. Dat', 'A0F063. Dat', 'A0F064. Dat', 'A0F065. Dat', 'A0F066. Dat', 'A0F067. Dat', 'A0F068. Dat', 'A0F069. Dat', 'A0F070. Dat'
'A0F071. Dat', 'A0F072. Dat', 'A0F073. Dat', 'A0F074. Dat', 'A0F075. Dat', 'A0F076. Dat', 'A0F077. Dat', 'A0F078. Dat', 'A0F079. Dat', 'A0F080. Dat'
'A0F081. Dat', 'A0F082. Dat', 'A0F083. Dat', 'A0F084. Dat', 'A0F085. Dat', 'A0F086. Dat', 'A0F087. Dat', 'A0F088. Dat', 'A0F089. Dat', 'A0F090. Dat'
'A0F091. Dat', 'A0F092. Dat', 'A0F093. Dat', 'A0F094. Dat', 'A0F095. Dat', 'A0F096. Dat', 'A0F097. Dat', 'A0F098. Dat', 'A0F099. Dat', 'A0F0100. Dat'
'A0F0101. Dat', 'A0F0102. Dat', 'A0F0103. Dat', 'A0F0104. Dat', 'A0F0105. Dat', 'A0F0106. Dat', 'A0F0107. Dat', 'A0F0108. Dat', 'A0F0109. Dat', 'A0F0110. Dat', 'A0F0111. Dat'] :
Myfile=open (filename, 'r')
data=https://bbs.csdn.net/topics/[]
For eachline in myfile:
Fileds=eachline. The split ()
row_data=https://bbs.csdn.net/topics/[float (x) for x fileds in]
Data. Append (row_data)
Dataa [t:, :]=data
T=t + 1
Myfile. Close ()
Dataa=np. Array (dataa)

# test set
T=0
Datab=np. Zeros ((nb, nd, 3))
For filename in [' OKLAHOMAA0F0. Dat] :
Myfile=open (filename, 'r')
data=https://bbs.csdn.net/topics/[]
For eachline in myfile:
Fileds=eachline. The split ()
row_data=https://bbs.csdn.net/topics/[float (x) for x fileds in]
Data. Append (row_data)
Datab [t:, :]=data
T=t + 1
Myfile. Close ()
Datab=np. Array (datab)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# design window, on the original logging curves are truncated, resistivity and translating
# x_trainb x_testb
Window_length=11
Nm=0
X_trainb=np. Zeros ((na * nc, window_length))
# yy_train_label=np. Zeros ((na * nc, window_length))
For ii in range (na) :
For jj in range (nc) :
For kk in range (window_length) :
If (jj - int (window_length/2) + kk) & lt; 0:
X_trainb [nm, kk]=1/dataa [ii, 0, 1]
# yy_train_label [nm, kk]=1/dataa [ii, 0, 2]
Elif (jj - int (window_length/2) + kk) & gt; Nc - 1:
X_trainb [nm, kk]=1/dataa [ii, nc - 1, 1] # 1/
# yy_train_label [nm, kk]=1/dataa [ii, nc - 1, 2] # 1
The else:
X_trainb [nm, kk]=1/dataa [ii, jj - int (window_length/2) + kk, 1] # 1/
# yy_train_label [nm, kk]=1/dataa [ii, jj - int (window_length/2) + kk, 2] # 1/
Nm=nm + 1

Nm=0
X_testb=np. Zeros ((nb * nd, window_length))
For ii in range (nb) :
For jj in range (nd) :
For kk in range (window_length) :
If (jj - int (window_length/2) + kk) & lt; 0:
X_testb [nm, kk]=1/datab [ii, 0, 1] # 1/
Elif (jj - int (window_length/2) + kk) & gt; Nd 1:
X_testb [nm, kk]=1/datab [ii, nd - 1, 1] # 1/
The else:
X_testb [nm, kk]=1/datab [ii, jj - int (window_length/2) + kk, 1] #
Nm=nm + 1
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# design tags to identify all the proportion of the resistive raised: 1, under resistive bump: 2, conductivity and raised: 0
Ytrain_label=[]
Label=[]
For ii in range (na) :
Temper=dataa [ii, 0, 2)
For jj in range (nc) :
If the int (temper/dataa [ii, jj, 2]) & lt; 203 and int (temper/dataa [ii, jj, 2]) & gt; 1.1 the and x_trainb [jj + nc * ii, int (window_length/2) - 1] <=x_trainb [jj + nc * ii, int (window_length/2)] :
# x_trainb [jj + na * ii, int (window_length/2) - 1] <=x_trainb [jj + na * ii, int (window_length/2) + 1] :
# raising
Tempera=jj + 2 * nc
Temperb=1
Label. Append (tempera)
Ytrain_label. Append (temperb)
Elif int (temper/dataa [ii, jj, 2]) & lt; 203 and int (temper/dataa [ii, jj, 2]) & gt; 1.1 the and x_trainb [jj + nc * ii, int (window_length/2) - 1) & gt; X_trainb [jj + nc * ii, int (window_length/2)] :
# x_trainb [jj + na * ii, int (window_length/2) - 1) & gt; X_trainb [jj + na * ii, int (window_length/2) + 1] :
# drop bump
Tempera=jj + 2 * nc
Temperb=2
Label. Append (tempera)
Ytrain_label. Append (temperb)
The else:
Tempera=jj + 2 * nc
Temperb=0
Label. Append (tempera)
Ytrain_label. Append (temperb)
Ytrain_label=np. Array (ytrain_label)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related