2016-08-11 4 views
0

ケネスをCNNに使用していますが、メモリリークが問題です。エラーはケラスを使用中にメモリエラーが発生しました

 [email protected]:~/12EC35005/MTP_Workspace/MTP$ python cnn_implement.py 
     Using Theano backend. 
     [INFO] compiling model... 
     Traceback (most recent call last): 
      File "cnn_implement.py", line 23, in <module> 
      model = CNNModel.build(width=150, height=150, depth=3) 
      File "/home/ms/anushreej/12EC35005/MTP_Workspace/MTP/cnn/networks/model_define.py", line 27, in build 
      model.add(Dense(depth*height*width)) 
      File "/home/ms/anushreej/anaconda3/lib/python3.5/site-packages/keras/models.py", line 146, in add 
      output_tensor = layer(self.outputs[0]) 
      File "/home/ms/anushreej/anaconda3/lib/python3.5/site-packages/keras/engine/topology.py", line 458, in __call__ 
      self.build(input_shapes[0]) 
      File "/home/ms/anushreej/anaconda3/lib/python3.5/site-packages/keras/layers/core.py", line 604, in build 
      name='{}_W'.format(self.name)) 
      File "/home/ms/anushreej/anaconda3/lib/python3.5/site-packages/keras/initializations.py", line 61, in glorot_uniform 
      return uniform(shape, s, name=name) 
      File "/home/ms/anushreej/anaconda3/lib/python3.5/site-packages/keras/initializations.py", line 32, in uniform 
      return K.variable(np.random.uniform(low=-scale, high=scale, size=shape), 
      File "mtrand.pyx", line 1255, in mtrand.RandomState.uniform (numpy/random/mtrand/mtrand.c:13575) 
      File "mtrand.pyx", line 220, in mtrand.cont2_array_sc (numpy/random/mtrand/mtrand.c:2902) 
     MemoryError 

です。なぜこれが起こっているのか理解できません。私のトレーニング画像は150 * 150 * 3サイズの非常に小さいです。

コードがある - :

 # import the necessary packages 
     from keras.models import Sequential 
     from keras.layers.convolutional import Convolution2D 
     from keras.layers.core import Activation 
     from keras.layers.core import Flatten 
     from keras.layers.core import Dense 

     class CNNModel: 
      @staticmethod 
      def build(width, height, depth): 
      # initialize the model 
      model = Sequential() 
      # first set of CONV => RELU 
      model.add(Convolution2D(50, 5, 5, border_mode="same", batch_input_shape=(None, depth, height, width))) 
      model.add(Activation("relu")) 

      # second set of CONV => RELU 
      # model.add(Convolution2D(50, 5, 5, border_mode="same")) 
      # model.add(Activation("relu")) 

      # third set of CONV => RELU 
      # model.add(Convolution2D(50, 5, 5, border_mode="same")) 
      # model.add(Activation("relu")) 

      model.add(Flatten()) 

      model.add(Dense(depth*height*width)) 

      # if weightsPath is not None: 
      # model.load_weights(weightsPath) 

      return model 
+0

メモリリークがあることをどのように知っていますか?そして別の問題はない? –

答えて

0

私は同じ問題に直面し、私は(私はそう差システムにしようとした問題は、平坦化層は、システムが処理できる以上のもの直前に数データポイントだと思います1つは高いラムが働いていて、少ないラムではこのエラーが出ました)。より多くのCNNレイヤーを追加してサイズを小さくして、それが機能する平坦化レイヤーを追加するだけです。

model = Sequential() model.add(Convolution2D(32, 3, 3,border_mode='same',input_shape=(1, 96, 96),activation='relu')) model.add(Convolution2D(64, 3, 3,border_mode='same',activation='relu')) model.add(MaxPooling2D((2,2), strides=(2,2))) model.add(Flatten()) model.add(Dense(1000,activation='relu')) model.add(Dense(97,activation='softmax'))

このdidntのはmodel = Sequential() model.add(Convolution2D(32, 3, 3,border_mode='same',input_shape=(1, 96, 96),activation='relu')) model.add(Convolution2D(64, 3, 3,border_mode='same',activation='relu')) model.add(MaxPooling2D((2,2), strides=(2,2))) model.add(Convolution2D(64, 3, 3,border_mode='same',activation='relu')) model.add(Convolution2D(128, 3, 3,border_mode='same',activation='relu')) model.add(MaxPooling2D((2,2), strides=(2,2))) model.add(Flatten()) model.add(Dense(1000,activation='relu')) model.add(Dense(97,activation='softmax')

はそれが役に立てば幸いエラーを与える:

これは私とエラーが発生しました。

関連する問題