AttributeError:模块“ keras.backend”没有属性“ set_image_dim_ordering”

时间:2019-09-22 02:38:14

标签: python keras conv-neural-network max-pooling

set_image_dim_ordering()

使用keras.backend中的AttributeError: module 'keras.backend' has no attribute 'set_image_dim_ordering'时出现错误

这是错误报告:import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) from keras.models import Sequential from keras.layers import Dense from keras.layers import Dropout from keras.layers import Flatten from keras.layers.convolutional import Convolution2D from keras.layers.convolutional import MaxPooling2D from sklearn.preprocessing import LabelEncoder,OneHotEncoder from keras import backend as K from subprocess import check_output

我的导入语句

# Read the input file as a whole (-Raw) and split it into blocks (paragraphs)
(Get-Content -Raw C:\scripts\file.txt) -split '\r?\n\r?\n' -ne '' |
  ForEach-Object { # Process each block
    # Initialize an ordered hashtable for the key-values pairs in this block.
    $oht = [ordered] @{}
    # Loop over the block's lines.
    foreach ($line in $_ -split '\r?\n' -ne '') {
      # Split the line into key and value...
      $key, $val = $line -split ':', 2
      # ... and add them to the hashtable.
      if ($key -like "*mac_address*"){
        $val = @($val.Replace(' ','').split(','))
      }
      $oht[$key.Trim()] = $val.Trim()
    }
    $oht # Output the hashtable.
  } | ConvertTo-Json

1 个答案:

答案 0 :(得分:1)

有几件事要看。这是known issue,针对2.2.5版进行了报告,但应在2.2.4及更低版本中使用。

但是,无论如何,您都应该停止使用此方法,因为它已经很旧并且已被image_data_format取代:[code]

keras.backend.image_data_format()
keras.backend.set_image_data_format(data_format)

它应该继续工作,但至少现在有一个错误。

编辑: 以下方法报告的海报似乎无效,但下面报告的海报不起作用或返回错误消息。

  

有些报告说您可以使用K.common访问该方法,但我尚未测试:

K.common.image_dim_ordering()
K.common.set_image_dim_ordering(dim_ordering)