@staticmethod
def colSpec(nparray: 'np.ndarray', rangeStr:str=None,batchStart:str=None, batchEnd:str=None)->'np.ndarray':
'''
Specify certain column data by selecting some columns or batched rows of data. --- UPDATED (Dexter) 20181210
Parameters
------------------------------
nparray `np.ndarray` - Data table to be selected.
rangeStr `str` - Index range string for selecting certain columns for the transformation.
batchStart `int` - The starting index (inclusive) of the data rows.
batchEnd `int` - The ending index (exclusive) of the data rows.
Returns
------------------------------
`np.ndarray` - Data table with requested selection range.
'''
# Convert to np array if it's not.
if not isinstance(nparray, np.ndarray):
if isinstance(nparray, list):
try:
nparray = np.array(nparray)
except:
raise ValueError("Data type not supported for colSpec. It should be an `np.ndarray` object.")
else:
raise ValueError("Data type not supported for colSpec. It should be an `np.ndarray` object.")
# If no column specification requested, just return the orginal array with batchStart and batchEnd rows.
if rangeStr is None:
return nparray[batchStart:batchEnd]
else:
colCount = len(nparray[0])
# Validate the index range range.
if (not IndexRange.validate(colCount, rangeStr)):
raise ValueError("Index range string is not valid.")
# Different scenarios on the column selections:
if ":" in rangeStr:
# Split the ":" to find the range start and end.
rangeInfo = [string.strip() for string in rangeStr.split(":")]
# None should be specified for 2-valued tuples.
if any([(ele == "None" or ele == "") for ele in rangeInfo]):
# Determine the scenarios for which None is used.
if rangeInfo[0] != "None" and len(rangeInfo[0]):
return nparray[batchStart:batchEnd,int(rangeInfo[0]):]
elif rangeInfo[1] != "None" and len(rangeInfo[1]):
return nparray[batchStart:batchEnd,:int(rangeInfo[1])]
else:
return nparray[batchStart:batchEnd]
else:
raise nparray[batchStart:batchEnd,int(rangeInfo[0]):int(rangeInfo[1])]
# Otherwise, it is specifying indexes explicitly.
else:
idxs = IndexRange.parse(colCount, rangeStr)
return nparray[batchStart:batchEnd,idxs]
Я не знаю, что не так, я даже не использую код исключений.
Я хочу использовать Python для обучения моего случая нейронной сети, но я признаю проблему. />[code]@staticmethod def colSpec(nparray: 'np.ndarray', rangeStr:str=None,batchStart:str=None, batchEnd:str=None)->'np.ndarray': ''' Specify certain column data by selecting some columns or batched rows of data. --- UPDATED (Dexter) 20181210
Parameters ------------------------------
nparray `np.ndarray` - Data table to be selected.
rangeStr `str` - Index range string for selecting certain columns for the transformation.
batchStart `int` - The starting index (inclusive) of the data rows.
batchEnd `int` - The ending index (exclusive) of the data rows.
Returns ------------------------------
`np.ndarray` - Data table with requested selection range. ''' # Convert to np array if it's not. if not isinstance(nparray, np.ndarray): if isinstance(nparray, list): try: nparray = np.array(nparray) except: raise ValueError("Data type not supported for colSpec. It should be an `np.ndarray` object.") else: raise ValueError("Data type not supported for colSpec. It should be an `np.ndarray` object.")
# If no column specification requested, just return the orginal array with batchStart and batchEnd rows. if rangeStr is None: return nparray[batchStart:batchEnd]
else: colCount = len(nparray[0])
# Validate the index range range. if (not IndexRange.validate(colCount, rangeStr)): raise ValueError("Index range string is not valid.")
# Different scenarios on the column selections: if ":" in rangeStr: # Split the ":" to find the range start and end. rangeInfo = [string.strip() for string in rangeStr.split(":")]
# None should be specified for 2-valued tuples. if any([(ele == "None" or ele == "") for ele in rangeInfo]): # Determine the scenarios for which None is used. if rangeInfo[0] != "None" and len(rangeInfo[0]): return nparray[batchStart:batchEnd,int(rangeInfo[0]):] elif rangeInfo[1] != "None" and len(rangeInfo[1]): return nparray[batchStart:batchEnd,:int(rangeInfo[1])] else: return nparray[batchStart:batchEnd] else: raise nparray[batchStart:batchEnd,int(rangeInfo[0]):int(rangeInfo[1])]
# Otherwise, it is specifying indexes explicitly. else: idxs = IndexRange.parse(colCount, rangeStr) return nparray[batchStart:batchEnd,idxs] [/code] Я не знаю, что не так, я даже не использую код исключений.
Я пытаюсь сделать паузу после игры. Я поднял подъем 'over!' в моей функции Game_over () в рамках класса game_snake2 и используется Try and, кроме как в run () Функция в одном и том же классе. Но, к сожалению, я получаю «TypeError: исключения должны...
Итак, я пытаюсь создать базовую ИНС, используя numpy. Дело в том, что я продолжаю получать прогноз точности около 10% и не понимаю, почему это так. Вот весь код.
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
Итак, я пытаюсь создать базовую ИНС, используя numpy. Дело в том, что я продолжаю получать прогноз точности около 10% и не понимаю, почему это так. Вот весь код.
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
Итак, я пытаюсь создать базовую ИНС, используя numpy. Дело в том, что я продолжаю получать прогноз точности около 10% и не понимаю, почему это так. Вот весь код.
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt