运行环境:%tensorflow_version 1.x
1.参数解析出错
源代码:
def parse_args():
parser = argparse.ArgumentParser(description="Run MLP.")
parser.add_argument('--path', nargs='?', default='Data/',
help='Input data path.')
parser.add_argument('--dataset', nargs='?', default='ml-1m',
help='Choose a dataset.')
parser.add_argument('--epochs', type=int, default=100,
help='Number of epochs.')
parser.add_argument('--batch_size', type=int, default=256,
help='Batch size.')
parser.add_argument('--layers', nargs='?', default='[64,32,16,8]',
help="Size of each layer. Note that the first layer is the concatenation of user and item embeddings. So layers[0]/2 is the embedding size.")
parser.add_argument('--reg_layers', nargs='?', default='[0,0,0,0]',
help="Regularization for each layer")
parser.add_argument('--num_neg', type=int, default=4,
help='Number of negative instances to pair with a positive instance.')
parser.add_argument('--lr', type=float, default=0.001,
help='Learning rate.')
parser.add_argument('--learner', nargs='?', default='adam',
help='Specify an optimizer: adagrad, adam, rmsprop, sgd')
parser.add_argument('--verbose', type=int, default=1,
help='Show performance per X iterations')
parser.add_argument('--out', type=int, default=1,
help='Whether to save the trained model.')
return parser.parse_args()
修改最后一句为return parser.parse_args(args=[])
。源代码在其他地方运行不会出错,在colab运行错误,可能是出于安全的考虑。
2.TypeError: init_normal() got an unexpected keyword argument 'dtype'
源代码:
def init_normal(shape, name=None):
return initializations.normal(shape, scale=0.01, name=name)
修改为:
def init_normal(shape, dtype=None):
return initializations.normal(shape, scale=0.01, name=name,dtype=dtype)
版本问题